fix: append /api/v3 and /api/graphql paths for GHEC Data Residency hosts
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()andNewRESTClient() -
apps.go:getInstallationAccessToken()
This ensures all non-api.github.com hosts (including *.ghe.com) will have the correct API paths appended.
Testing
- [x] All existing tests pass
- [x] Manually tested with a real GHEC Data Residency environment (
hidden-staging.ghe.com) - [x]
terraform plansuccessfully refreshes all GitHub resources
Related Issues
Fixes the issue reported in the diff comparison: https://github.com/integrations/terraform-provider-github/compare/v6.5.0...v6.6.0#diff-062b7a475c9ddd7765fd96c620a3f7854307a4b68c0ff57db24b9d912b5bcec9R88
👋 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! 🚀