{"record":{"id":"999a4ca827597e41","repo":"hashicorp/terraform","slug":"failed-to-decode-state-store-s-nested-provider-con","errorCode":null,"errorMessage":"failed to decode state_store's nested provider config: %w","messagePattern":"failed to decode state_store's nested provider config: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/workdir/statestore_config_state.go","lineNumber":131,"sourceCode":"//\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\n\treturn plans.NewStateStore(s.Type, providerVersion, s.Provider.Source, storeConfigVal, storeSchema, providerConfigVal, providerSchema, workspaceName)\n}\n\nfunc (s *StateStoreConfigState) DeepCopy() *StateStoreConfigState {","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/command/workdir/statestore_config_state.go#L113-L149","documentation":"Counterpart to 774, but for the nested provider block's config. At statestore_config_state.go:129, s.Provider.Config(providerSchema) decodes the provider's ConfigRaw against the provider schema's implied cty type. Failure indicates the stored provider config doesn't conform to the current provider schema.","triggerScenarios":"s.Provider.Config(providerSchema) returns an error from ctyjson.Unmarshal — provider schema drift or corrupt provider ConfigRaw.","commonSituations":"Provider upgraded after the state_store record was written, changing nested provider argument types; partial write of provider config bytes.","solutions":["Re-run 'terraform init' to re-encode the provider config against the current provider schema.","Follow the provider upgrade guide if mid-version migration.","Inspect the wrapped cty error to find the offending provider argument."],"exampleFix":"// before\nError: failed to decode state_store's nested provider config: ...attribute \"region\": string required\n\n// after\n$ rm -rf .terraform && terraform init\n$ terraform plan -out=tfplan","handlingStrategy":"try-catch","validationCode":"// Probe-decode the nested provider config before PlanData.\nif _, err := s.Provider.Config(providerSchema); err != nil {\n    return fmt.Errorf(\"nested provider config will not decode: %w\", err)\n}","typeGuard":"null","tryCatchPattern":"if _, err := s.PlanData(storeSchema, provSchema, ws); err != nil {\n    if strings.Contains(err.Error(), \"nested provider config\") {\n        // provider schema drift; re-init\n    }\n}","preventionTips":["Re-init after provider upgrades before producing plans.","Pin provider versions to prevent silent schema changes.","Validate provider config decodability in init-path tests."],"tags":["terraform","plan","provider","schema","decode"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}