{"record":{"id":"234bc39c8308b682","repo":"hashicorp/terraform","slug":"failed-to-read-remote-state-s-234bc3","errorCode":null,"errorMessage":"failed to read remote state: %s","messagePattern":"failed to read remote state: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/backend/remote-state/oss/client.go","lineNumber":433,"sourceCode":"\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error getting bucket %s: %#v\", c.bucketName, err)\n\t}\n\n\tif exist, err := bucket.IsObjectExist(c.stateFile); err != nil {\n\t\treturn nil, fmt.Errorf(\"estimating object %s is exist got an error: %#v\", c.stateFile, err)\n\t} else if !exist {\n\t\treturn nil, nil\n\t}\n\n\tvar options []oss.Option\n\toutput, err := bucket.GetObject(c.stateFile, options...)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error getting object: %#v\", err)\n\t}\n\n\tbuf := bytes.NewBuffer(nil)\n\tif _, err := io.Copy(buf, output); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to read remote state: %s\", err)\n\t}\n\tsum := md5.Sum(buf.Bytes())\n\tpayload := &remote.Payload{\n\t\tData: buf.Bytes(),\n\t\tMD5:  sum[:],\n\t}\n\n\t// If there was no data, then return nil\n\tif len(payload.Data) == 0 {\n\t\treturn nil, nil\n\t}\n\n\treturn payload, nil\n}\n\nconst errBadChecksumFmt = `state data in OSS does not have the expected content.\n\nThis may be caused by unusually long delays in OSS processing a previous state","sourceCodeStart":415,"sourceCodeEnd":451,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/backend/remote-state/oss/client.go#L415-L451","documentation":"Thrown by RemoteClient.getObj when io.Copy from the OSS GetObject response body into an in-memory buffer fails. The object was opened successfully; the failure is a streaming read error mid-download. The %s formats the underlying error (usually a network or connection reset).","triggerScenarios":"io.Copy(buf, output) returns err != nil while streaming the object body. Causes: connection reset by OSS, premature close, client timeout mid-download, large state file exceeding a proxy buffer, or a reader that returned EOF incorrectly.","commonSituations":"Flaky network to OSS region; large state files (tens of MB) over a constrained CI network; corporate proxy terminating long reads; transient OSS-side connection drop.","solutions":["Retry the apply/init - streaming errors are typically transient.","Reduce state size by splitting resources or using workspaces to shrink each state file.","Run from a host in the same region as the OSS bucket (lower latency, fewer resets).","Disable or reconfigure any HTTP proxy that truncates long responses."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// set a per-read budget sized for the state file\nctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)\ndefer cancel()\n// pass ctx to the SDK call so streaming reads respect the deadline","typeGuard":null,"tryCatchPattern":"for attempt := 0; attempt < 3; attempt++ {\n    output, err := bucket.GetObject(c.stateFile)\n    if err != nil { return err }\n    buf := bytes.NewBuffer(nil)\n    if _, err := io.Copy(buf, output); err == nil { break } else { lastErr = err }\n}\n","preventionTips":["Run from a host in the OSS bucket's region.","Shrink large state files (split into workspaces/modules).","Disable corporate proxies that truncate long reads."],"tags":["oss","alibaba","network","streaming","io"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}