{"record":{"id":"ad1d90c80337004f","repo":"hashicorp/terraform","slug":"unable-to-determine-if-provider-s-is-reattached-w","errorCode":null,"errorMessage":"Unable to determine if provider %s is reattached while initializing the state store. This is a bug in Terraform and should be reported: %v","messagePattern":"Unable to determine if provider (.+?) is reattached while initializing the state store\\. This is a bug in Terraform and should be reported: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/command/meta_config.go","lineNumber":496,"sourceCode":"\t\tif m.View != nil {\n\t\t\tm.View.SetConfigSources(loader.Sources)\n\t\t}\n\t}\n\treturn m.configLoader, nil\n}\n\n// registryClient instantiates and returns a new Terraform Registry client.\nfunc (m *Meta) registryClient() *registry.Client {\n\treturn registry.NewClient(m.Services, nil)\n}\n\nfunc (m *Meta) getProviderSupplyModeForStateStore(config *configs.Module) getproviders.ProviderSupplyMode {\n\tif config == nil || config.StateStore == nil {\n\t\treturn getproviders.Unset\n\t}\n\tisReattached, err := reattach.IsProviderReattached(config.StateStore.ProviderAddr, os.Getenv(\"TF_REATTACH_PROVIDERS\"))\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"Unable to determine if provider %s is reattached while initializing the state store. This is a bug in Terraform and should be reported: %v\", config.StateStore.ProviderAddr.ForDisplay(), err))\n\t}\n\treturn getproviders.DetermineProviderSupplyMode(m.isProviderDevOverride(config.StateStore.ProviderAddr), isReattached, config.StateStore.ProviderAddr.IsBuiltIn())\n}\n\n// configValueFromCLI parses a configuration value that was provided in a\n// context in the CLI where only strings can be provided, such as on the\n// command line or in an environment variable, and returns the resulting\n// value.\nfunc configValueFromCLI(synthFilename, rawValue string, wantType cty.Type) (cty.Value, tfdiags.Diagnostics) {\n\tvar diags tfdiags.Diagnostics\n\n\tswitch {\n\tcase wantType.IsPrimitiveType():\n\t\t// Primitive types are handled as conversions from string.\n\t\tval := cty.StringVal(rawValue)\n\t\tvar err error\n\t\tval, err = convert.Convert(val, wantType)\n\t\tif err != nil {","sourceCodeStart":478,"sourceCodeEnd":514,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/command/meta_config.go#L478-L514","documentation":"Programmer-error panic in getProviderSupplyModeForStateStore: reattach.IsProviderReattached returned an error when parsing TF_REATTACH_PROVIDERS for the state-store provider address. Rather than propagating the error, the code panics with the provider display name and the wrapped error. The message labels it a Terraform bug.","triggerScenarios":"TF_REATTACH_PROVIDERS environment variable is set (provider dev mode) but contains malformed JSON for the state-store provider entry, causing IsProviderReattached to return a non-nil err.","commonSituations":"Provider development workflow with a malformed TF_REATTACH_PROVIDERS payload; leftover/stale reattach env var pointing at a non-existent provider; editing the env var by hand introducing a syntax error.","solutions":["Unset or correct TF_REATTACH_PROVIDERS (ensure it is valid JSON with the right provider source address and protocol/port).","If not developing a state-store provider, remove the env var entirely.","Regenerate the reattach config using the provider's dev tooling."],"exampleFix":"# before\nexport TF_REATTACH_PROVIDERS='{malformed json'\n\n# after\nunset TF_REATTACH_PROVIDERS\n# or, valid:\nexport TF_REATTACH_PROVIDERS='{\"registry.terraform.io/hashicorp/local\":{\"Protocol\":\"grpc\",\"ProtocolVersion\":6,\"Pid\":12345,\"Test\":true,\"Addr\":{\"Network\":\"unix\",\"String\":\"/tmp/plugin\"}}}'","handlingStrategy":"validation","validationCode":"// Validate the reattach env var before relying on it.\nif raw := os.Getenv(\"TF_REATTACH_PROVIDERS\"); raw != \"\" {\n    if _, err := reattach.ParseProviders(raw); err != nil {\n        return getproviders.Unset, fmt.Errorf(\"invalid TF_REATTACH_PROVIDERS: %w\", err)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Unset TF_REATTACH_PROVIDERS when not developing providers.","Regenerate the env var from provider dev tooling rather than editing by hand.","Validate the JSON before launching Terraform in dev mode."],"tags":["terraform","state-store","provider-dev","reattach","panic","env-var"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}