Skip to content

fix: append /api/v3 and /api/graphql paths for GHEC Data Residency hosts#2997

Closed
JiayangZhou wants to merge 2 commits intointegrations:mainfrom
JiayangZhou:fix/ghec-data-residency-api-path
Closed

fix: append /api/v3 and /api/graphql paths for GHEC Data Residency hosts#2997
JiayangZhou wants to merge 2 commits intointegrations:mainfrom
JiayangZhou:fix/ghec-data-residency-api-path

Conversation

@JiayangZhou
Copy link
Copy Markdown
Contributor

@JiayangZhou JiayangZhou commented Dec 12, 2025

Description

This PR fixes a regression introduced in v6.6.0 where GHEC Data Residency hosts (*.ghe.com) were incorrectly treated like github.com, resulting in the API being unreachable.

Problem

In PR #2547, support for GHEC Data Residency was added with the assumption that *.ghe.com hosts behave like github.com (i.e., they don't need /api/v3 or /api/graphql/ paths). However, this assumption is incorrect - these hosts actually behave like GitHub Enterprise Server and do require the API paths.

Symptoms

  • With v6.5.0: Users configured base_url = "https://customer.ghe.com/api/v3" and it worked
  • With v6.6.0: Validation requires removing /api/v3, but then the provider fails to reach the API
  • Error: this resource can only be used in the context of an organization, "ORG_NAME" is a user

Solution

Remove the GHECDataResidencyHostMatch exclusion from the path construction logic in:

  • config.go: NewGraphQLClient() and NewRESTClient()
  • apps.go: getInstallationAccessToken()

This ensures all non-api.github.com hosts (including *.ghe.com) will have the correct API paths appended.

Testing

  • All existing tests pass
  • Manually tested with a real GHEC Data Residency environment (hidden-staging.ghe.com)
  • terraform plan successfully refreshes all GitHub resources

Related Issues

Fixes the issue reported in the diff comparison: v6.5.0...v6.6.0#diff-062b7a475c9ddd7765fd96c620a3f7854307a4b68c0ff57db24b9d912b5bcec9R88

GHEC Data Residency hosts (*.ghe.com) require the /api/v3 and /api/graphql/
paths to be appended, similar to GitHub Enterprise Server instances.

The original PR integrations#2547 incorrectly assumed that GHEC Data Residency hosts
behave like github.com (without requiring /api/v3 path). However, in practice
these hosts behave like GHE Server and need the API paths appended.

This fix removes the GHECDataResidencyHostMatch exclusion from the path
construction logic, so all non-github.com hosts (including *.ghe.com) will
have the correct API paths appended.

Fixes the regression introduced in v6.6.0 where users had to remove /api/v3
from their base_url but the provider then failed to reach the API correctly.
@github-actions github-actions Bot added the Type: Bug Something isn't working as documented label Dec 12, 2025
@github-actions
Copy link
Copy Markdown

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

Comment thread github/apps.go Outdated
if hostname != DotComHost && !GHECDataResidencyHostMatch.MatchString(hostname) {
if hostname != DotComHost {
// GHE Server and GHEC Data Residency hosts need /api/v3 path
baseURL.Path = path.Join(baseURL.Path, "api/v3/")
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we start to append api/v3/ for GHEC Data Residency hosts? @deiga please have a look at this Pr when you get time thanks!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry just pulled upstream, i think it already contained the fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Bug Something isn't working as documented

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant