Skip to content

"Decoding state file failed: json: cannot unmarshal number" when in a working directory initialized by an earlier version #19146

@apparentlymart

Description

@apparentlymart

Terraform Version

Terraform v0.12.0-alpha1

Expected Behavior

After upgrading to Terraform v0.12, it should be possible to run terraform init and have it automatically update the .terraform/terraform.tfstate file and other internal state information within the .terraform directory for any new file formats introduced in the new release.

Actual Behavior

For a working directory that was previously initialized with Terraform 0.11 or earlier, the hashing function used for backend configuration may have generated a number bigger than what is expected by the new parser for the backend metadata file:

Error: Failed to load state: Decoding state file failed: json: cannot unmarshal number 14885267135666261723 into Go struct field BackendState.hash of type int

Workaround

To work around this for v0.12.0-alpha1, remove the file .terraform/terraform.tfstate and run terraform init again to re-generate it. (Note that .terraform/terraform.tfstate is not the same as terraform.tfstate; deleting the latter will cause Terraform to lose track of any resources it is managing.)

Please note that we do not recommend using remote state backends with v0.12.0-alpha1, since this prerelease version is focused on the configuration language changes and so the remote state backends have not been extensively tested.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions