{"record":{"id":"d069d94d92d5c6fc","repo":"hashicorp/terraform","slug":"failed-to-decode-state-store-config-w","errorCode":null,"errorMessage":"failed to decode state_store config: %w","messagePattern":"failed to decode state_store config: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/workdir/statestore_config_state.go","lineNumber":127,"sourceCode":"\n// PlanData produces an alternative representation of the receiver that is\n// suitable for storing in a plan. The current workspace must additionally\n// be provided, to be stored alongside the state store configuration.\n//\n// The state_store configuration schema is required in order to properly\n// encode the state store-specific configuration settings.\nfunc (s *StateStoreConfigState) PlanData(storeSchema *configschema.Block, providerSchema *configschema.Block, workspaceName string) (*plans.StateStore, error) {\n\tif s == nil {\n\t\tpanic(\"PlanData called on a nil *StateStoreConfigState receiver. This is a bug in Terraform and should be reported.\")\n\t}\n\n\tif err := s.Validate(); err != nil {\n\t\treturn nil, fmt.Errorf(\"error when preparing state store config for planfile: %s\", err)\n\t}\n\n\tstoreConfigVal, err := s.Config(storeSchema)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to decode state_store config: %w\", err)\n\t}\n\tproviderConfigVal, err := s.Provider.Config(providerSchema)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to decode state_store's nested provider config: %w\", err)\n\t}\n\n\tvar providerVersion *version.Version\n\tswitch s.ProviderSupplyMode {\n\tcase getproviders.BuiltIn, getproviders.Reattached, getproviders.DevOverride:\n\t\t// For built-in providers, reattached providers, and developer overrides, we don't require version information to be present in the state file, so we should be tolerant of it being missing.\n\t\t// In this case we can just use a placeholder version that will never actually be used for anything, but allows us to avoid returning an error when trying to save state store data to a plan file.\n\t\tproviderVersion = version.Must(version.NewVersion(\"0.0.0\"))\n\tcase getproviders.ManagedByTerraform:\n\t\tproviderVersion = s.Provider.Version\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"State store provider %q (%s) has unknown supply mode %q. This is a bug in Terraform and should be reported.\", s.Provider.Source.Type, s.Provider.Source.ForDisplay(), s.ProviderSupplyMode))\n\t}\n","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/command/workdir/statestore_config_state.go#L109-L145","documentation":"StateStoreConfigState.PlanData called s.Config(storeSchema) and decoding failed; the %w wraps the cty decoder error. This happens when the raw config bytes in ConfigRaw don't conform to the state_store type's schema while building the plan's StateStore block.","triggerScenarios":"Plan-time decoding of the state_store config against the registered schema — unknown arguments, wrong types, or a schema that changed since the file was written (e.g. provider upgrade changed the schema without re-init).","commonSituations":"Switching provider versions without `terraform init`, schema-breaking provider updates, hand-edited ConfigRaw, or downgrade across a schema-changing release.","solutions":["Run `terraform init` so ConfigRaw is rewritten against the current schema.","Inspect the wrapped error for the offending argument; fix in the state_store block and re-init.","Upgrade/downgrade to align Terraform and provider versions, then re-init."],"exampleFix":"# before — plan fails decoding state_store config\nterraform plan\n\n# after — re-init then plan\nterraform init\nterraform plan","handlingStrategy":"validation","validationCode":"// pre-flight: decode the config separately to give a targeted error\nif _, err := s.Config(storeSchema); err != nil {\n    return nil, fmt.Errorf(\"state_store config no longer matches schema; run `terraform init`: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"storeConfigVal, err := s.Config(storeSchema)\nif err != nil {\n    return nil, fmt.Errorf(\"failed to decode state_store config: %w; re-run `terraform init`\", err)\n}","preventionTips":["Run `terraform init` after provider upgrades.","Pin provider versions in .terraform.lock.hcl."],"tags":["backend","state-store","config-decode","schema-mismatch","plan"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}