terraform-provider-github
terraform-provider-github copied to clipboard
[BUG]: github_ip_ranges unable to parse meta endpoint.
Expected Behavior
The following will provide a list of IP addresses:
data "github_ip_ranges" "default" {}
Actual Behavior
It fails with the following:
Error: json: cannot unmarshal object into Go struct field APIMeta.domains of type []string with data.github_ip_ranges.default on github.tf line 1, in data "github_ip_ranges" "default":
data "github_ip_ranges" "default" {}
Terraform Version
Terraform v1.9.4 + github provider 6.2.3
Affected Resource(s)
- github_ip_ranges
Terraform Configuration Files
data "github_ip_ranges" "default" {}
Steps to Reproduce
$ terraform plan
Debug Output
No response
Panic Output
No response
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
Seems like it works when downgrading the provider to 6.2.2. It only fails with 6.2.3.
🫡 Same error here, gonna use:
provider "github" {
version = "6.2.2"
}
for now (using Terraform v1.9.4 with it)
A little investigations:
The resource github_ip_ranges depends on api.github.com/meta via APIMeta struct type of google/go-github.
- https://github.com/integrations/terraform-provider-github/blob/c3b7085229ed84f7924b7d07718ed9a5c57c2304/github/data_source_github_ip_ranges.go#L157
- https://github.com/google/go-github/blob/882755a047ea3e09b2f5f4a0e888d9a12cf2852f/github/meta.go#L19-L76
The error described above, "cannot unmarshal object into Go struct field APIMeta.domains of type []string with data.github_ip_ranges.default", says that field APIMeta.domains is the cause of error. APIMeta.domains is defined as map[string][]string json:"domains,omitempty" in go-github:
- https://github.com/google/go-github/blob/882755a047ea3e09b2f5f4a0e888d9a12cf2852f/github/meta.go#L75
However, observing the actual response from api.github.com/meta, there are artifact_attestations property under domains, with schema that deviates from the []string form -- there are trust_domain field with string and services field with array of strings.
Note that the API document of GitHub about this endpoint does not mention about the artifact_attestations field.
Personally, I feel this is most likely an upstream google/go-github issue. On the other hand, this is likely to involve incompatible changes to the API, which seems like a difficult problem.
I found that the Domains field in APIMeta introduced in https://github.com/google/go-github/pull/3121, which included in v62.0.0 release of google/go-github.
As far as I can see, google/go-github's version is upgraded in https://github.com/integrations/terraform-provider-github/pull/2304, which included in v6.2.3 release of terraform-provider-github.
However, if this is happening with an older version, as is also the case at https://github.com/integrations/terraform-provider-github/issues/2357#issuecomment-2304608543 then I don't know what could be causing this.
Now that the upstream issue has been resolved in https://github.com/google/go-github/pull/3249 (cc https://github.com/google/go-github/issues/3248), all we have to do is wait for the next release 👀
Got the same issue, on a mac.
macOS Sonoma 14.5
➜ terraform --version
Terraform v1.9.4
on darwin_arm64
+ provider registry.terraform.io/hashicorp/aws v5.61.0
+ provider registry.terraform.io/hashicorp/helm v2.14.0
+ provider registry.terraform.io/hashicorp/kubernetes v2.31.0
+ provider registry.terraform.io/hashicorp/random v3.6.2
+ provider registry.terraform.io/integrations/github v6.2.2
+ provider registry.terraform.io/oboukili/argocd v6.1.1
Your version of Terraform is out of date! The latest version
is 1.9.5. You can update by downloading from https://www.terraform.io/downloads.html
Going back to 6.2.2 did the trick.
EDIT
Updated terraform to the latest and it still fail with 6.2.3
still fails with 6.3.0
still fails with 6.3.0
Same for me
The upstream problem is resolved and released in https://github.com/google/go-github/pull/3266 as go-github v65.0.0, so https://github.com/integrations/terraform-provider-github/pull/2359 should fix this issue
v6.3.1 included #2359 and seems to be back to working.
👋 Hey Friends, this issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Please add the Status: Pinned label if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!