{"record":{"id":"374518c3aa18ca16","repo":"hashicorp/terraform","slug":"attempted-to-initialize-pluggable-state-with-a-nil","errorCode":null,"errorMessage":"Attempted to initialize pluggable state with a nil provider interface. This is a bug in Terraform and should be reported","messagePattern":"Attempted to initialize pluggable state with a nil provider interface\\. This is a bug in Terraform and should be reported","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/backend/pluggable/pluggable.go","lineNumber":38,"sourceCode":"\n// NewPluggable returns a Pluggable. A Pluggable fulfils the\n// backend.Backend interface and allows management of state via\n// a state store implemented in the provider that's within the Pluggable.\n//\n// These are the assumptions about that\n// provider:\n// * The provider implements at least one state store.\n// * The provider has already been fully configured before using NewPluggable.\n//\n// The state store could also be configured prior to using NewPluggable,\n// but preferably it will be configured via the Pluggable,\n// using the relevant backend.Backend methods.\n//\n// By wrapping a configured provider in a Pluggable we allow calling code\n// to use the provider's gRPC methods when interacting with state.\nfunc NewPluggable(p providers.Interface, typeName string) (*Pluggable, error) {\n\tif p == nil {\n\t\treturn nil, errors.New(\"Attempted to initialize pluggable state with a nil provider interface. This is a bug in Terraform and should be reported\")\n\t}\n\tif typeName == \"\" {\n\t\treturn nil, errors.New(\"Attempted to initialize pluggable state with an empty string identifier for the state store. This is a bug in Terraform and should be reported\")\n\t}\n\n\treturn &Pluggable{\n\t\tprovider: p,\n\t\ttypeName: typeName,\n\t}, nil\n}\n\nvar _ backend.Backend = &Pluggable{}\n\ntype Pluggable struct {\n\tprovider providers.Interface\n\ttypeName string\n}\n","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/backend/pluggable/pluggable.go#L20-L56","documentation":"Returned by NewPluggable (internal/backend/pluggable/pluggable.go:38) when the providers.Interface argument p is nil. Pluggable wraps an already-configured provider to expose its state store via the backend.Backend interface; a nil provider cannot service any gRPC call. The message explicitly states this is a bug in Terraform, not a user/config error.","triggerScenarios":"Internal Terraform code calling NewPluggable(nil, typeName) because provider instantiation failed earlier and the nil was not guarded before reaching this constructor. It is a programmer/invariant violation in the terraform binary itself.","commonSituations":"A regression in terraform core where provider factory returns nil on error and the caller forwards it; a faulty custom build; an edge case during provider plugin crash/handshake that yields a nil interface despite no error.","solutions":["Report the bug to the Terraform maintainers with the full log and stack trace, as the message instructs.","Upgrade or downgrade Terraform to a known-good version (this is a core invariant bug, not config).","Check that your provider plugin actually started (plugin handshake logs) — a crashed provider can surface as nil upstream."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Guard the constructor precondition at the call site.\nif p == nil {\n    return nil, fmt.Errorf(\"cannot build pluggable backend: provider is nil (upstream provider error)\")\n}\nreturn pluggable.NewPluggable(p, typeName)","typeGuard":null,"tryCatchPattern":"pb, err := pluggable.NewPluggable(p, typeName)\nif err != nil {\n    // This is an internal bug; report it rather than retrying.\n    return fmt.Errorf(\"internal terraform error: %w\", err)\n}","preventionTips":["Always check provider factory errors before forwarding the provider to NewPluggable.","Treat a nil provider with a non-nil error from the factory as fatal.","Report these as bugs; do not build retry logic around internal invariants."],"tags":["backend","pluggable","provider","nil-pointer","internal-bug"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}