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

Error creating droplet: JSON unmarshal issue with large number into Go struct field type int #1183

Open
tlserver opened this issue Jul 24, 2024 · 3 comments
Labels

Comments

@tlserver
Copy link

Bug Report


Describe the bug

When attempting to create a Droplet using Terraform, an error occurs indicating that a number in the JSON response cannot be unmarshaled into a Go struct field of type int. This seems to be due to the ID number being larger than the maximum value for an int in Go.

Affected Resource(s)

  • digitalocean_droplet

Expected Behavior

The Droplet should be created successfully without any errors.

Actual Behavior

The Droplet is created but an error make terraform stopped.

╷
│ Error: Error creating droplet: json: cannot unmarshal number 2215418155 into Go struct field LinkAction.links.actions.id of type int
│ 
│   with digitalocean_droplet.app_net,
│   on do-droplets.tf line 1, in resource "digitalocean_droplet" "app_net":
│    1: resource "digitalocean_droplet" "app_net" {
│ 
╵

Steps to Reproduce

  1. Define a Droplet resource in Terraform.
  2. Run terraform apply.

Terraform Configuration Files

provider "digitalocean" {}

resource "digitalocean_droplet" "app_net" {
  name     = "AppNet"
  image    = "ubuntu-24-04-x64"
  size     = "s-1vcpu-512mb-10gb"
  region   = "sgp1"
  ipv6     = true
}

Terraform version

Terraform v1.9.2
on windows_386
+ provider registry.terraform.io/1password/onepassword v2.1.0
+ provider registry.terraform.io/digitalocean/digitalocean v2.39.2
+ provider registry.terraform.io/hashicorp/google v5.38.0
+ provider registry.terraform.io/hashicorp/google-beta v5.38.0
+ provider registry.terraform.io/hashicorp/random v3.6.2

Debug Output
Gist

Panic Output
No panic output.

Additional context

The issue appears to be related to the JSON response from the DigitalOcean API containing an ID number that is too large for an int field in the Go struct. Since 2,215,418,155 ( 840C 992B ) > 2,147,483,647 ( 7FFF FFFF ) which is the max number of int32. The type of these large number field should be changed to uint32 or int64 instead of int32.

Important Factoids
No custom images or kernels are being used.

References
#151

@tlserver tlserver added the bug label Jul 24, 2024
@tlserver
Copy link
Author

I am using Windows and found that this issue only occurs with the 386 (32-bit) version of Terraform, but not with the AMD64 (64-bit) version. You can download different versions of Terraform here.

@nicholasmireles
Copy link

I had the same issue and was able to resolve it by using the 64-bit executable as mentioned above. It is rather confusing that the 64-bit is called AMD.

@eliseodesign
Copy link

tuve el mismo maldito problema, te odio windows

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

No branches or pull requests

3 participants