{"record":{"id":"59726916ab34620b","repo":"hashicorp/terraform","slug":"failed-to-set-state-store-provider-configuration-597269","errorCode":null,"errorMessage":"Failed to set state store provider configuration: %w","messagePattern":"Failed to set state store provider configuration: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/state_migrate.go","lineNumber":315,"sourceCode":"\t\tbsf.StateStore = &workdir.StateStoreConfigState{\n\t\t\tType: rootMod.StateStore.Type,\n\t\t\tHash: uint64(cHash),\n\t\t\tProvider: &workdir.ProviderConfigState{\n\t\t\t\tSource:  &rootMod.StateStore.ProviderAddr,\n\t\t\t\tVersion: version,\n\t\t\t},\n\t\t\tProviderSupplyMode: rootMod.StateStore.ProviderSupplyMode,\n\t\t}\n\t\terr = bsf.StateStore.SetConfig(stateStoreConfigVal, dstB.ConfigSchema())\n\t\tif err != nil {\n\t\t\tdiags = diags.Append(fmt.Errorf(\"Failed to set state store configuration: %w\", err))\n\t\t\tview.Diagnostics(diags)\n\t\t\treturn 1\n\t\t}\n\n\t\terr = bsf.StateStore.Provider.SetConfig(providerConfigVal, dstB.ProviderSchema())\n\t\tif err != nil {\n\t\t\tdiags = diags.Append(fmt.Errorf(\"Failed to set state store provider configuration: %w\", err))\n\t\t\tview.Diagnostics(diags)\n\t\t\treturn 1\n\t\t}\n\n\t} else {\n\t\tdiags = diags.Append(tfdiags.Sourceless(\n\t\t\ttfdiags.Error,\n\t\t\t\"Unknown migration destination\",\n\t\t\t\"No configuration was provided for where to migrate the state to. Please ensure that a file with a .tf extension is present and contains valid state_store or backend configuration inside the terraform block.\",\n\t\t))\n\t}\n\n\t// present all errors from above together so user can fix them all at once\n\tif diags.HasErrors() {\n\t\tview.Diagnostics(diags)\n\t\treturn 1\n\t}\n\tview.LogMigrationDestinationInitializationComplete()","sourceCodeStart":297,"sourceCodeEnd":333,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/command/state_migrate.go#L297-L333","documentation":"Thrown immediately after [749] when bsf.StateStore.Provider.SetConfig(providerConfigVal, dstB.ProviderSchema()) fails. This is the state-store *provider's* own configuration (the nested provider {} block), distinct from the state_store block itself. Uses %w.","triggerScenarios":"The provider schema for the state-store provider rejects the nested provider config value: required provider attribute missing, wrong type, or ProviderSchema() returned empty because the plugin handshake failed silently.","commonSituations":"Nested `provider` block inside `state_store` missing required fields; provider binary is wrong version vs the schema Terraform cached; dev-override provider with stale schema; provider plugin crashed during schema response.","solutions":["Read the wrapped err for the attribute that failed validation.","Run `terraform init -upgrade` to fetch a provider binary whose schema matches your config.","Confirm the nested `provider {}` block matches the provider's documented required arguments.","Remove dev overrides for that provider and retry."],"exampleFix":"// before: nested provider missing region\n state_store \"xyz\" {\n   provider {\n     token = var.token\n   }\n }\n\n// after\n state_store \"xyz\" {\n   provider {\n     token  = var.token\n     region = \"us-east-1\"\n   }\n }","handlingStrategy":"validation","validationCode":"// Pre-validate the nested provider block against its schema.\nif _, diags := dstB.ProviderSchema().Validate(providerConfigVal); diags.HasErrors() {\n    return diags\n}","typeGuard":null,"tryCatchPattern":"if err := bsf.StateStore.Provider.SetConfig(providerConfigVal, dstB.ProviderSchema()); err != nil {\n    diags = diags.Append(fmt.Errorf(\"Failed to set state store provider configuration: %w\", err))\n    view.Diagnostics(diags)\n    hintReinitForFreshProviderSchema(view)\n    return 1\n}","preventionTips":["Match the nested provider {} block to the provider's documented required args.","Run `terraform init -upgrade` after bumping the state-store provider version.","Remove dev overrides before running state migrations.","Inspect provider logs (TF_LOG=TRACE) if ProviderSchema() looks empty."],"tags":["terraform","state-migration","state-store","provider","config","schema"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}