{"record":{"id":"4a3276aa87d56273","repo":"hashicorp/terraform","slug":"unable-to-read-content-from-response-w","errorCode":null,"errorMessage":"unable to read 'content' from response: %w","messagePattern":"unable to read 'content' from response: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/backend/remote-state/oci/client.go","lineNumber":107,"sourceCode":"\t\tgetRequest.OpcSseCustomerKeySha256 = common.String(c.SSECustomerKeySHA256)\n\t\tgetRequest.OpcSseCustomerAlgorithm = common.String(c.SSECustomerAlgorithm)\n\t}\n\t// Get object from OCI\n\tgetResponse, err := c.objectStorageClient.GetObject(ctx, getRequest)\n\tif err != nil {\n\t\tvar ociErr common.ServiceError\n\t\tif errors.As(err, &ociErr) {\n\t\t\treturn nil, fmt.Errorf(\"failed to access object HttpStatusCode: %d\\nOpcRequestId: %s\\n message: %s\\n ErrorCode: %s\", ociErr.GetHTTPStatusCode(), ociErr.GetOpcRequestID(), ociErr.GetMessage(), ociErr.GetCode())\n\n\t\t}\n\t\treturn nil, fmt.Errorf(\"failed to access object '%s' in bucket '%s': %w\", c.path, c.bucketName, err)\n\t}\n\tdefer getResponse.Content.Close()\n\n\t// Read object content\n\tcontentArray, err := io.ReadAll(getResponse.Content)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to read 'content' from response: %w\", err)\n\t}\n\n\t// Compute MD5 hash\n\tmd5Hash := getResponse.ContentMd5\n\tif md5Hash == nil || len(*md5Hash) == 0 {\n\t\tmd5Hash = getResponse.OpcMultipartMd5\n\t}\n\t// Construct payload\n\tpayload := &remote.Payload{\n\t\tData: contentArray,\n\t\tMD5:  []byte(*md5Hash),\n\t}\n\n\t// Return an error instead of `nil, nil` if the object is empty\n\tif len(payload.Data) == 0 {\n\t\treturn nil, fmt.Errorf(\"object %q is empty\", c.path)\n\t}\n","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/backend/remote-state/oci/client.go#L89-L125","documentation":"Head and Get both succeeded (headers and an open body stream were returned), but io.ReadAll failed while streaming the body. The connection dropped mid-download, the server reset the stream, or the context was cancelled during the read.","triggerScenarios":"Server or proxy closed the connection mid-stream; client context cancelled; truncated response; socket read timeout hit during a large state download.","commonSituations":"Large state files over flaky networks; proxy buffering timeouts; CI runners with aggressive idle-read timeouts; the connection died between receiving headers and the full body.","solutions":["Retry the Get — the state file did not change, only the stream broke.","Stabilize the network path for large transfers (wired CI runner, less lossy route).","Reduce state size (split into workspaces, prune stale resources) to make transfers more resilient.","Confirm the HTTP client read timeout exceeds the slowest expected download."],"exampleFix":"// before: single shot Get on a flaky link\npayload, err := client.Get()\n// after: retry read failures specifically\nfor i := 0; i < 3; i++ {\n    payload, err = client.Get()\n    if err == nil { break }\n    if strings.Contains(err.Error(), \"unable to read 'content'\") {\n        time.Sleep(backoff(i)); continue\n    }\n    break\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":"func isBodyReadErr(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"unable to read 'content'\")\n}","tryCatchPattern":"// Read-content failures are transient; retry the whole Get\nfor i := 0; i < 3; i++ {\n    payload, err := c.Get()\n    if err == nil { return payload, nil }\n    if !isBodyReadErr(err) { return nil, err }\n    time.Sleep(backoff(i))\n}","preventionTips":["Use a stable, low-loss network path for large state downloads.","Keep the HTTP client read timeout above the slowest expected transfer.","Reduce state size so partial-stream failures are less likely.","Monitor download retry counts as a leading indicator of network issues."],"tags":["oci","object-storage","io","network"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}