-
Notifications
You must be signed in to change notification settings - Fork 741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG]: github_branch data source constructs incorrect API URL for public repo #1938
Comments
Hey @NickFitz thank you for hunting this down and apologies for the trouble. I am going to assign the labels |
I can confirm that behaviour, will check it |
I believe I'm running into this issue with a private repository: I look up an existing repository:
to try and create a branch:
And the URL that's produced and produces a 404:
The $user value correctly identifies the user of the token which I am using in my provider instantiation. |
We also hit this type of issue on a private repo, trying to generate actions environment secrets:
The personal access token used for auth has access granted to the organisation.
|
👋 Hey Friends, this issue has been automatically marked as |
Expected Behavior
Given the provider configuration:
the data source:
is expected to result in
data.github_branch.main
having the attributes documented at https://registry.terraform.io/providers/integrations/github/latest/docs/data-sources/branch relating to the GitHub repository atsomeorg/some_public_repository
.Examining the
DEBUG
logs shows that the path being requested from the GitHub API iswhen it should be
Setting the
GITHUB_OWNER
environment variable does not resolve the issue. It appears from the debug output that the absence of a token (which is not required as the repository is public) causes the data source to configure an anonymous owner. But an anonymous owner does not seem to have a name, and therefore the interpolation of the owner name as the organisation name in URL construction fails, resulting in the//
seen in the URL.This appears to be the same, or very similar, behaviour to that identified in issue #942 with the
github_repository_file
data source. A fix for that issue is in #1494, and from comparing that PR and the corresponding code ingithub_branch
, I believe the fix would be the same or very similar. I also suspect the same issue may be present in other data sources.Actual Behavior
The attributes of
data.github_branch.main
are allnull
due to the malformed path in the API request, which results in a404 Not Found
response.Terraform Version
Affected Resource(s)
Terraform Configuration Files
No response
Steps to Reproduce
Debug Output
Panic Output
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: