integrations / terraform-provider-github

Terraform GitHub provider
https://www.terraform.io/docs/providers/github/
MIT License
906 stars 747 forks source link

[BUG]: github_ip_ranges unable to parse meta endpoint. #2357

Open nairb774 opened 2 months ago

nairb774 commented 2 months ago

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)

Terraform Configuration Files

data "github_ip_ranges" "default" {}

Steps to Reproduce

$ terraform plan

Debug Output

No response

Panic Output

No response

Code of Conduct

legoscia commented 2 months ago

Seems like it works when downgrading the provider to 6.2.2. It only fails with 6.2.3.

fideloper commented 2 months ago

🫡 Same error here, gonna use:

provider "github" {
  version = "6.2.2" 
}

for now (using Terraform v1.9.4 with it)

polamjag commented 2 months ago

A little investigations:

The resource github_ip_ranges depends on api.github.com/meta via APIMeta struct type of google/go-github.

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:

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.

polamjag commented 2 months ago

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.

polamjag commented 2 months ago

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 👀

gabrielstuff commented 2 months ago

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

devopsrick commented 1 month ago

still fails with 6.3.0

priyashpatil commented 1 month ago

still fails with 6.3.0

Same for me

polamjag commented 1 month ago

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

nairb774 commented 1 month ago

v6.3.1 included #2359 and seems to be back to working.