Skip to content

Fixing team repository permissions - #1384

Merged
nickfloyd merged 4 commits into
integrations:mainfrom
elliottpope:FixingTeamRepositoryPermissions
Nov 28, 2022
Merged

nickfloyd merged 4 commits into
integrations:mainfrom
elliottpope:FixingTeamRepositoryPermissions

Conversation

@elliottpope

@elliottpope elliottpope commented Nov 23, 2022 •

Copy link
Copy Markdown
Contributor

Resolves #1373


Behavior

Before the change?

  • Accept header was overwritten by previewHeaderInjectorTransport which caused errors in github_team_repository which needs the vnd.github.v3.repository+json value to be present in the Accept header.

After the change?

  • previewHeaderInjectorTransport appends the preview schema to the existing Accept header (Go implementation will return default "" - empty string - when header not set so logic will work even if Accept header not already set) as a comma-separated list

Other information

No other info


Additional info

Pull request checklist

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)
  • Added the appropriate label for the given change

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes (Please add the Type: Breaking change label)
  • No

If Yes, what's the impact:

  • N/A

Pull request type

Please add the corresponding label for change this PR introduces:

  • Bugfix: Type: Bug

Accept header was getting overwritten by the previewHeaderInjectorTransport
previewHeaderInjectorTransport is a workaround since go-github/githubv4 dependencies do not allow specifying arbitrary headers to be added to requests and the preview Accept schema needed to be added for the github_team_settings resource
New implementation reads the existing header value and appends the value as a comma separated list
This will work at least for the Accept header (other headers may not work this way so this API will need to be used with caution - but it is package private so only changes to the provider could cause this issue)
@elliottpope

Copy link
Copy Markdown
Contributor Author

Verified that without this change the github_team_repository_test.go tests (TestAccGithubTeamRepository) fail and when the change is introduced, they pass.

Command to isolate the github_team_repository tests:

TF_ACC=1 GITHUB_TOKEN=<your GitHub PAT> GITHUB_OWNER=<your account> GITHUB_ORGANIZATION=
<your org> TF_LOG=debug go test -v ./github -run 'TestAccGithubTeamRepository'

@elliottpope
elliottpope marked this pull request as ready for review November 23, 2022 20:49
@elliottpope elliottpope mentioned this pull request Nov 23, 2022
1 of 5 tasks
If header is empty string then we do not want '' + ',' + header = ,header so checking for empty string before concatenating
@scruplelesswizard

Copy link
Copy Markdown

@elliottpope Thanks for adding this feature set and getting the bug patched!

@elliottpope

Copy link
Copy Markdown
Contributor Author

My bad, it was a dumb mistake to override the header 🤦‍♂️

@nickfloyd nickfloyd left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! ❤️

@nickfloyd nickfloyd added Type: Bug Something isn't working as documented Priority: High labels Nov 28, 2022
@nickfloyd
nickfloyd merged commit a92f786 into integrations:main Nov 28, 2022
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.

[BUG]: github_team_repository error with version 5.9.0 - fails with at least one permission expected from permissions map

3 participants