Skip to content
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

Unsupported (?) API call to github API causes github pages to not work properly #1198

Closed
timon-michel-svga opened this issue Jun 21, 2022 · 2 comments · Fixed by #1258
Closed

Comments

@timon-michel-svga
Copy link

Impacted resource: github_repository

If we want to change the publishing source for a github repository, the provider uses the following arguments:

2022-06-21T11:41:13.197+0200 [DEBUG] provider.terraform-provider-github_v4.26.1: -----------------------------------------------------
2022-06-21T11:41:13.197+0200 [DEBUG] provider.terraform-provider-github_v4.26.1: 2022/06/21 11:41:13 [DEBUG] Github API Request Details:
2022-06-21T11:41:13.197+0200 [DEBUG] provider.terraform-provider-github_v4.26.1: ---[ REQUEST ]---------------------------------------
2022-06-21T11:41:13.197+0200 [DEBUG] provider.terraform-provider-github_v4.26.1: PUT /repos/Scopevisio/TestRepo/pages HTTP/1.1
2022-06-21T11:41:13.197+0200 [DEBUG] provider.terraform-provider-github_v4.26.1: Host: api.github.com
2022-06-21T11:41:13.197+0200 [DEBUG] provider.terraform-provider-github_v4.26.1: User-Agent: go-github
2022-06-21T11:41:13.197+0200 [DEBUG] provider.terraform-provider-github_v4.26.1: Content-Length: 37
2022-06-21T11:41:13.197+0200 [DEBUG] provider.terraform-provider-github_v4.26.1: Accept: application/vnd.github.v3+json
2022-06-21T11:41:13.198+0200 [DEBUG] provider.terraform-provider-github_v4.26.1: Content-Type: application/json
2022-06-21T11:41:13.198+0200 [DEBUG] provider.terraform-provider-github_v4.26.1: Accept-Encoding: gzip
2022-06-21T11:41:13.198+0200 [DEBUG] provider.terraform-provider-github_v4.26.1: 
2022-06-21T11:41:13.198+0200 [DEBUG] provider.terraform-provider-github_v4.26.1: {
2022-06-21T11:41:13.198+0200 [DEBUG] provider.terraform-provider-github_v4.26.1:  "cname": null,
2022-06-21T11:41:13.198+0200 [DEBUG] provider.terraform-provider-github_v4.26.1:  "source": "main /docs"
2022-06-21T11:41:13.198+0200 [DEBUG] provider.terraform-provider-github_v4.26.1: }
2022-06-21T11:41:13.198+0200 [DEBUG] provider.terraform-provider-github_v4.26.1: 

The documentation of the Github API, however specify a different method to set the branch and path:

{
"cname": null,
"source": {"branch":"main","path":"/docs"}
}

(https://docs.github.com/en/rest/pages#update-information-about-a-github-pages-site)

If we make the request using the method used by the terraform provider, we get an error:

2022-06-21T11:41:14.382+0200 [ERROR] vertex "github_repository.test" error: PUT https://api.github.com/repos/Scopevisio/TestRepo/pages: 422 Invalid request.

Invalid property /source: `main /docs` is not a possible value. Must be one of the following: gh-pages, master, master /docs. []

We can replicate this issue in CURL, but if we use the way provided in the GitHub API documentation it works flawlessly.

I am no expert in Go, but the corresponding source seems to be here:

source += fmt.Sprintf(" %s", v)

@gesellix
Copy link
Contributor

gesellix commented Jul 6, 2022

The internally used google/go-github module might need a change, see google/go-github#2406

@gesellix
Copy link
Contributor

go-github has been released as v46.0.0, including the required change to allow main as pages source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants