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

Failure unmarshalling organization with large PrivateRepos number in plan #2736

Closed
shaines1 opened this issue Apr 5, 2023 · 5 comments · Fixed by #2738
Closed

Failure unmarshalling organization with large PrivateRepos number in plan #2736

shaines1 opened this issue Apr 5, 2023 · 5 comments · Fixed by #2738
Assignees
Labels
Breaking API Change PR will require a bump to the major version num in next release. Look here to see the change(s).

Comments

@shaines1
Copy link

shaines1 commented Apr 5, 2023

Hello,

I am attempting to use the integrations/github Terraform provider with GitHub Enterprise Server. Executing terraform plan and terraform apply with infrastructure definitions that require interacting with organizations hosted in the GHES instance result in the following go-github error:

│ Error: json: cannot unmarshal number 999999999999 into Go struct field Plan.plan.private_repos of type int
│
│   with data.github_organization.architecture,
│   on main.tf line 14, in data "github_organization" "myorg":
│   14: data "github_organization" "myorg" {

On inspection of the organization JSON representation, the plan.private_repos has a value of 999999999999. My assumption is that the unmarshalling error is due to the PrivateRepos variable in go-github only being declared as an int.

Here's an abbreviated snippet of the organization JSON output:

{
  "login": "myorg",
  "id": 1,
  "plan": {
    "name": "enterprise",
    "space": 1,
    "private_repos": 999999999999,
    "filled_seats": 1,
    "seats": 0
  }
}

Would it be possible to modify this data type? Please let me know if there's anything else that would be helpful to provide!

Environment

  • GitHub Enterprise Server: 3.8.0
  • Terraform: 1.4.2
  • integrations/github: 5.20
  • go-github: v50.2.0
@gmlewis
Copy link
Collaborator

gmlewis commented Apr 5, 2023

Something seems fishy here... have you looked at the JSON output directly from the server (using curl for example)?
Is it really sending that number?!? Doesn't that seem like a GitHub problem? Have you contacted GitHub tech support?

@shaines1
Copy link
Author

shaines1 commented Apr 5, 2023

Something seems fishy here...

I agree

have you looked at the JSON output directly from the server (using curl for example)? Is it really sending that number?!?

Yes. Using an PAT as an org owner to https://<base_url>/api/v3/orgs/<org_name> with Postman returns the same result. It doesn't appear to be a permission issue, as the remainder of the response looks correct

image

Doesn't that seem like a GitHub problem? Have you contacted GitHub tech support?

Yes, my colleague has. I'll update here with their response when we receive it

@MISO-mgriffin
Copy link

MISO-mgriffin commented Apr 5, 2023

Received confirmation from GitHub that this is the expected value when using GitHub Enterprise Server. This library will need to be updated to accommodate the larger value.

The GitHub Enterprise Server plan, by design, returns 999999999999. GitHub Enterprise Cloud returns 999999 however. As 999999999999 is larger than a 32-bit int, you'll need to be able to handle this in your code/that of libraries you use.

@gmlewis
Copy link
Collaborator

gmlewis commented Apr 5, 2023

@MISO-mgriffin - thank you!
I'll put together a PR for a breaking change, one moment.

@gmlewis gmlewis added the Breaking API Change PR will require a bump to the major version num in next release. Look here to see the change(s). label Apr 5, 2023
@gmlewis gmlewis self-assigned this Apr 5, 2023
@gmlewis
Copy link
Collaborator

gmlewis commented Apr 5, 2023

@shaines1 and/or @MISO-mgriffin - could you please review (and LGTM+Approve if you agree) with #2738 when you have a moment?

gmlewis added a commit that referenced this issue Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking API Change PR will require a bump to the major version num in next release. Look here to see the change(s).
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants