{"record":{"id":"0826685e3212ed0e","repo":"hashicorp/terraform","slug":"failed-obtain-the-in-use-version-of-provider-s","errorCode":null,"errorMessage":"Failed obtain the in-use version of provider %s (%q) used with state store %q. This is a bug in Terraform and should be reported: %w","messagePattern":"Failed obtain the in-use version of provider (.+?) \\(%q\\) used with state store %q\\. This is a bug in Terraform and should be reported: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/meta_backend.go","lineNumber":2478,"sourceCode":"\n\tpLock := locks.Provider(c.ProviderAddr)\n\tif pLock == nil {\n\t\tdiags = diags.Append(tfdiags.Sourceless(\n\t\t\ttfdiags.Error,\n\t\t\t\"Inconsistent dependency lock file\",\n\t\t\tfmt.Sprintf(`The provider dependency used for state storage is missing from the lock file despite being present in the current configuration:\n  - provider %s: required by this configuration but no version is selected\n\nTo make the initial dependency selections that will initialize the dependency lock file, run:\n  terraform init`,\n\t\t\t\tc.ProviderAddr,\n\t\t\t),\n\t\t))\n\t\treturn nil, diags\n\t}\n\tpVersion, err := providerreqs.GoVersionFromVersion(pLock.Version())\n\tif err != nil {\n\t\tdiags = diags.Append(fmt.Errorf(\"Failed obtain the in-use version of provider %s (%q) used with state store %q. This is a bug in Terraform and should be reported: %w\",\n\t\t\tc.Provider.Name,\n\t\t\tc.ProviderAddr,\n\t\t\tc.Type,\n\t\t\terr))\n\t\treturn nil, diags\n\t}\n\n\treturn pVersion, diags\n}\n\n// Initializing a saved state store from the backend state file (aka 'cache file', aka 'legacy state file')\nfunc (m *Meta) savedStateStore(sMgr *clistate.LocalState) (backend.Backend, tfdiags.Diagnostics) {\n\t// We're preparing a state_store version of backend.Backend.\n\t//\n\t// The provider and state store will be configured using the backend state file.\n\n\tvar diags tfdiags.Diagnostics\n","sourceCodeStart":2460,"sourceCodeEnd":2496,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/command/meta_backend.go#L2460-L2496","documentation":"In getStateStorageProviderVersion (meta_backend.go:2478), Terraform reads the locked provider version from the dependency lock file via pLock.Version() and converts it with providerreqs.GoVersionFromVersion. If that conversion fails, the version recorded in .terraform.lock.hcl is unparseable. The message explicitly says this is a Terraform bug and should be reported.","triggerScenarios":"The lock file contains a provider version constraint that does not parse as a concrete version (e.g. malformed, empty, or a constraint where a version is expected); a lock file produced by a buggy/older Terraform that wrote an incompatible version field; manual edits to .terraform.lock.hcl.","commonSituations":"Hand-editing .terraform.lock.hcl, a lock file shared/rewritten across incompatible Terraform versions, or a core bug writing a bad version field.","solutions":["Regenerate the lock file: back up .terraform.lock.hcl, delete it, and run `terraform init` to rewrite valid entries.","If reproducible with a clean lock file, report it as a Terraform bug with the provider address and state-store type from the message.","Verify the provider's version in the lock file is a concrete semver (e.g. 1.2.3), not a constraint (e.g. ~>1.2).","Ensure you are on a current Terraform release to avoid a known version-writing regression."],"exampleFix":"// before: terraform init   (fails: Failed obtain the in-use version of provider ... This is a bug)\n// after: cp .terraform.lock.hcl .terraform.lock.hcl.bak && rm .terraform.lock.hcl && terraform init","handlingStrategy":"validation","validationCode":"// Validate every provider entry in the lock file is a concrete, parseable version.\nfunc lockFileVersionsParseable(path string) error {\n    locks, diags := depsfile.LoadLocksFromFile(path)\n    if diags.HasErrors() { return diags.Err() }\n    for _, p := range locks.AllProviders() {\n        if _, err := providerreqs.GoVersionFromVersion(locks.Provider(p).Version()); err != nil {\n            return fmt.Errorf(\"provider %s has unparseable version: %w\", p, err)\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never hand-edit .terraform.lock.hcl; regenerate with `terraform init`.","Commit a lock file produced by a current Terraform version.","Treat a non-semver provider version in the lock file as corrupt.","Keep Terraform core up to date to avoid version-writing regressions."],"tags":["state-store","provider","lock-file","internal-bug","init"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}