{"record":{"id":"f4ede74022db30bf","repo":"hashicorp/terraform","slug":"failed-to-load-state-s-f4ede7","errorCode":null,"errorMessage":"Failed to load state: %s","messagePattern":"Failed to load state: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/output.go","lineNumber":88,"sourceCode":"\t}\n\n\t// Command can be aborted by interruption signals\n\tctx, done := c.InterruptibleContext(c.CommandContext())\n\tdefer done()\n\n\t// This is a read-only command\n\tc.ignoreRemoteVersionConflict(b)\n\n\tenv, err := c.Workspace()\n\tif err != nil {\n\t\tdiags = diags.Append(fmt.Errorf(\"Error selecting workspace: %s\", err))\n\t\treturn nil, diags\n\t}\n\n\t// Get the state\n\tsMgr, sDiags := b.StateMgr(env)\n\tif sDiags.HasErrors() {\n\t\tdiags = diags.Append(fmt.Errorf(\"Failed to load state: %s\", sDiags.Err()))\n\t\treturn nil, diags\n\t}\n\n\toutput, err := sMgr.GetRootOutputValues(ctx)\n\tif err != nil {\n\t\treturn nil, diags.Append(err)\n\t}\n\n\treturn output, diags\n}\n\nfunc (c *OutputCommand) Help() string {\n\thelpText := `\nUsage: terraform [global options] output [options] [NAME]\n\n  Reads an output variable from a Terraform state file and prints\n  the value. With no additional arguments, output will display all\n  the outputs for the root module.  If NAME is not specified, all","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/command/output.go#L70-L106","documentation":"After resolving the workspace, OutputCommand retrieves the state manager via b.StateMgr(env). If the returned diagnostics have errors, this message wraps diags.Err() and aborts. This is a backend-layer failure accessing the state store for the chosen workspace, not a state-decode failure.","triggerScenarios":"b.StateMgr(env) returns sDiags with HasErrors() true — e.g. the backend cannot authenticate to the state bucket, the configured state backend is invalid, or the workspace key prefix is malformed.","commonSituations":"S3 remote state with missing/revoked AWS credentials; DynamoDB lock table removed; Consul/HTTP backend endpoint unreachable; backend block reconfigured without terraform init; workspace state object deleted out-of-band.","solutions":["Run terraform init to reconfigure the backend after any backend block change.","Verify credentials, endpoints, and permissions for the state backend (e.g. AWS creds with s3:GetObject on the state key).","Ensure the lock table / KV path referenced by the backend still exists.","Inspect diags.Err() in the %s for the backend-specific failure reason."],"exampleFix":"# before: state backend auth fails\nterraform output\n# after: refresh creds + reinit\nexport AWS_PROFILE=state-read\nterraform init\nterraform output","handlingStrategy":"validation","validationCode":"// Probe backend state access before the command.\nif _, d := b.StateMgr(env); d.HasErrors() {\n    return fmt.Errorf(\"state backend unavailable; check creds and run 'terraform init': %s\", d.Err())\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run terraform init after any backend block change.","Use least-privilege credentials scoped to the state objects.","Verify the lock table / KV path still exists for remote state."],"tags":["terraform","state","backend","output","auth","remote-state"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}