{"record":{"id":"5bffe2461b34c2e1","repo":"hashicorp/terraform","slug":"could-not-read-state-version-outputs-w","errorCode":null,"errorMessage":"could not read state version outputs: %w","messagePattern":"could not read state version outputs: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cloud/state.go","lineNumber":572,"sourceCode":"\t\tso, err = s.tfeClient.StateVersionOutputs.ReadCurrent(ctx, s.workspace.ID)\n\n\t\tif err != nil {\n\t\t\tif strings.Contains(err.Error(), \"service unavailable\") {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\treturn NonRetryableError{err}\n\t\t}\n\t\treturn nil\n\t})\n\n\tif err != nil {\n\t\tswitch err {\n\t\tcase context.DeadlineExceeded:\n\t\t\treturn nil, fmt.Errorf(\"current outputs were not ready to be read within the deadline. Please try again\")\n\t\tcase context.Canceled:\n\t\t\treturn nil, fmt.Errorf(\"canceled reading current outputs\")\n\t\t}\n\t\treturn nil, fmt.Errorf(\"could not read state version outputs: %w\", err)\n\t}\n\n\tresult := make(map[string]*states.OutputValue)\n\n\tfor _, output := range so.Items {\n\t\tif output.DetailedType == nil {\n\t\t\t// If there is no detailed type information available, this state was probably created\n\t\t\t// with a version of terraform < 1.3.0. In this case, we'll eject completely from this\n\t\t\t// function and fall back to the old behavior of reading the entire state file, which\n\t\t\t// requires a higher level of authorization.\n\t\t\tlog.Printf(\"[DEBUG] falling back to reading full state\")\n\n\t\t\tif err := s.RefreshState(); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"failed to load state: %w\", err)\n\t\t\t}\n\n\t\t\tstate := s.State()\n\t\t\tif state == nil {","sourceCodeStart":554,"sourceCodeEnd":590,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/cloud/state.go#L554-L590","documentation":"Thrown by GetRootOutputValues when RetryBackoff returns a non-nil error that is neither context.DeadlineExceeded nor context.Canceled — i.e., a FatalError was encountered (the inner function returned NonRetryableError). The %w wraps the fatal inner error, which originates from StateVersionOutputs.ReadCurrent returning a non-'service unavailable' error.","triggerScenarios":"StateVersionOutputs.ReadCurrent returns a non-retryable error such as 401/403 (auth/permission), 404 (workspace or state version gone), or a malformed response; the error string does not contain 'service unavailable' so it is wrapped in NonRetryableError and RetryBackoff stops immediately.","commonSituations":"Expired or insufficient API token when reading outputs; workspace permissions changed to read-only for a role that cannot read state version outputs; workspace or state version deleted between the run and the output read; TFE API returning an unexpected error format.","solutions":["Check the wrapped error for HTTP status: 401/403 means auth/permissions, 404 means the resource is gone","Verify the authenticated identity has permission to read state version outputs on the workspace","Confirm the workspace and its current state version still exist","Retry the terraform command if the error appears transient (network blips producing unexpected error bodies)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Before calling GetRootOutputValues, verify read permissions for outputs:\nws, err := tfeClient.Workspaces.Read(ctx, organization, workspaceName)\nif err != nil {\n    return err\n}\nif ws.CurrentStateVersion == nil {\n    return fmt.Errorf(\"no current state version; outputs may not be readable\")\n}","typeGuard":null,"tryCatchPattern":"outputs, err := state.GetRootOutputValues(ctx)\nif err != nil && strings.Contains(err.Error(), \"could not read state version outputs\") {\n    // non-retryable (fatal) error from TFE — check auth/permissions\n    return nil, fmt.Errorf(\"output read failed (likely auth/permissions): %w\", err)\n}\nreturn outputs, err","preventionTips":["Ensure the CI/service account token has state-version-output read permission","Do not change workspace permissions mid-operation","Verify the workspace and current state version exist before reading outputs"],"tags":["outputs","tfe","authentication","permissions","retry","terraform"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}