{"record":{"id":"54c2100889e75fbc","repo":"hashicorp/terraform","slug":"failed-to-load-state-w","errorCode":null,"errorMessage":"failed to load state: %w","messagePattern":"failed to load state: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cloud/state.go","lineNumber":586,"sourceCode":"\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 {\n\t\t\t\t// We know that there is supposed to be state (and this is not simply a new workspace\n\t\t\t\t// without state) because the fallback is only invoked when outputs are present but\n\t\t\t\t// detailed types are not available.\n\t\t\t\treturn nil, ErrStateVersionUnauthorizedUpgradeState\n\t\t\t}\n\n\t\t\treturn state.RootOutputValues, nil\n\t\t}\n\n\t\tif output.Sensitive {\n\t\t\t// Since this is a sensitive value, the output must be requested explicitly in order to\n\t\t\t// read its value, which is assumed to be present by callers\n\t\t\tsensitiveOutput, err := s.tfeClient.StateVersionOutputs.Read(ctx, output.ID)\n\t\t\tif err != nil {","sourceCodeStart":568,"sourceCodeEnd":604,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/cloud/state.go#L568-L604","documentation":"When an output has no DetailedType (state written by Terraform < 1.3.0), GetRootOutputValues falls back to reading the entire state file, which requires higher authorization. This wraps a failure of that RefreshState() fallback.","triggerScenarios":"Legacy state lacking detailed output types, and the full-state refresh (which needs elevated read authorization) fails.","commonSituations":"Old workspaces never upgraded to the modern state format, or a token without full-state-read permission against legacy state.","solutions":["Upgrade the state: run an apply/refresh with Terraform >= 1.3 to rewrite state with detailed output types.","Grant the token permission to read the full state.","Re-run after the upgrade so the fallback path is no longer needed."],"exampleFix":"# before: legacy state from TF < 1.3 + token without full-state read -> failed to load state\n# after: upgrade state format, then read outputs\nterraform apply    # rewrite state with detailed output types (TF >= 1.3)\nterraform output","handlingStrategy":"validation","validationCode":"// Detect legacy state lacking detailed output types and upgrade proactively\nsv, err := client.StateVersions.ReadCurrent(ctx, workspace.ID)\nif err == nil && sv != nil {\n    // require TF >= 1.3 to have written detailed types; otherwise plan an upgrade apply\n}","typeGuard":null,"tryCatchPattern":"outs, err := state.GetRootOutputValues(ctx)\nif err != nil {\n    if errors.Is(err, cloud.ErrStateVersionUnauthorizedUpgradeState) {\n        // upgrade state with TF >= 1.3 then retry\n    }\n    return err\n}","preventionTips":["Upgrade legacy workspaces with TF >= 1.3 to write detailed output types","Grant full-state read if legacy fallback is unavoidable","Re-run after upgrading the state format"],"tags":["state-read","legacy","fallback","version","auth"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}