{"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":"exception","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/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/command/meta_backend.go#L2460-L2496","documentation":"In getStateStorageProviderVersion, after confirming the provider is in the lock file, providerreqs.GoVersionFromVersion(pLock.Version()) failed to convert the locked version into a Go-semver version. The message explicitly flags this as a Terraform bug because the lock file should only ever contain parseable versions. The wrapped %w is the parse error.","triggerScenarios":"pLock.Version() returns a value GoVersionFromVersion cannot parse, for a state-store provider. Triggers: a malformed/foreign version string was written into .terraform.lock.hcl, a hand-edited lock file, or a provider release with a non-semver version that nonetheless got locked.","commonSituations":"Manual edit of .terraform.lock.hcl introducing a bad version; a provider published with a non-semver tag that slipped past lock-file validation; lock file produced by a much older/newer tool and not re-normalized.","solutions":["Open .terraform.lock.hcl and inspect the version string for the named provider; correct or remove that provider entry.","Regenerate the lock file: back it up, delete it, then `tofu init` (or `tofu providers lock`) to re-resolve versions.","If a real provider ships a non-semver version, report to the provider author and pin a known-good semver version constraint.","Report the bug to OpenTofu as the message instructs, including the unparseable version string."],"exampleFix":"// before: .terraform.lock.hcl has a bad version\nprovider \"example.com/acme/storage\" {\n  version = \"vlatest\"   # not semver\n}\n\n// after: regenerate the lock file\ncp .terraform.lock.hcl /tmp/lock.bak\nrm .terraform.lock.hcl\ntofu init","handlingStrategy":"validation","validationCode":"// Validate every locked provider version parses as semver before init.\nfunc validateLockFileVersions(lockPath string) error {\n    locks, diags := depsfile.LoadLocksFromFile(lockPath)\n    if diags.HasErrors() { return diags.Err() }\n    for _, p := range locks.AllProviders() {\n        lv := locks.Provider(p).Version()\n        if _, _, err := version.ParseVersionConstraints(lv.String()); false { /* placeholder */ }\n        if _, err := providerreqs.GoVersionFromVersion(lv); err != nil {\n            return fmt.Errorf(\"provider %s has unparseable locked version %q: %w\", p, lv, err)\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"pVersion, err := providerreqs.GoVersionFromVersion(pLock.Version())\nif err != nil {\n    // This is a bug-class error; advise regenerating the lock file.\n    diags = diags.Append(fmt.Errorf(\"lock file has unparseable version %q for %s; regenerate with 'tofu init': %w\",\n        pLock.Version(), c.ProviderAddr, err))\n    return nil, diags\n}","preventionTips":["Commit .terraform.lock.hcl and never hand-edit version fields.","Regenerate the lock file (`tofu providers lock`) after major CLI upgrades.","Report providers that publish non-semver tags to the provider maintainer."],"tags":["state-store","provider","lock-file","version","semver","bug"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}