{"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/c9def3e214014c1188faabfc4a5bde5095139765/internal/backend/remote-state/oss/client.go#L415-L451","documentation":"Thrown in oss/client.go:433 inside getObj() after GetObject succeeded, when io.Copy from the response body stream into the in-memory buffer fails. The object was opened and metadata fetched, but the byte stream could not be fully read to completion. This is a transport-level failure on an otherwise-valid response.","triggerScenarios":"The TCP connection is reset or dropped mid-transfer, OSS closes the response body early, a read timeout fires, or an intermediary (proxy/CDN) truncates the body. Large state files over an unstable link are the classic trigger.","commonSituations":"CI runner on a flaky network/VPN; very large state file transferred over a slow or metered link; corporate forward proxy buffering and then aborting; OSS internally retried and returned a partial body.","solutions":["Retry the Terraform operation — stream-read failures are almost always transient.","Stabilize the network path (avoid VPN/proxy hops, run from a host in the same region as the OSS bucket).","Reduce state size by splitting resources into more workspaces/states to shrink the transferred payload.","If recurring, capture a packet/proxy log to confirm truncation and report to network/OSS support."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Stream-read failures warrant a bounded retry on the whole Get\n// for attempt := 0; attempt < 3; attempt++ {\n//   payload, diags := client.Get()\n//   if !diags.HasErrors() { return payload, nil }\n//   time.Sleep((1 << attempt) * time.Second)\n// }","preventionTips":["Run from a host in the OSS bucket's region to minimize mid-stream drops.","Keep state files small via workspace/resource splitting.","Avoid VPN/proxy hops that truncate large responses."],"tags":["oss","alibaba-cloud","network","io","remote-state"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T20:17:04.800Z"}