{"record":{"id":"b7458fbb186b0cfe","repo":"hashicorp/terraform","slug":"error-getting-object-v","errorCode":null,"errorMessage":"error getting object: %#v","messagePattern":"error getting object: %#v","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/backend/remote-state/oss/client.go","lineNumber":428,"sourceCode":"\treturn fmt.Sprintf(\"%s/%s\", c.bucketName, c.stateFile)\n}\n\nfunc (c *RemoteClient) getObj() (*remote.Payload, error) {\n\tbucket, err := c.ossClient.Bucket(c.bucketName)\n\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","sourceCodeStart":410,"sourceCodeEnd":446,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/backend/remote-state/oss/client.go#L410-L446","documentation":"Thrown by the Alibaba Cloud OSS backend's RemoteClient.getObj() (oss/client.go:428) when bucket.GetObject() fails downloading the state file. The prior IsObjectExist check already passed, so the bucket/object resolved but the actual GET returned a non-nil error from the aliyun-oss-go-sdk. It surfaces during any Terraform operation that reads remote state (state pull, plan, apply, refresh). The raw SDK error is formatted with %#v so the concrete *oss.ServiceError is visible.","triggerScenarios":"bucket.GetObject(c.stateFile) returns err: expired or invalid STS/AccessKey credentials, RAM principal lacking oss:GetObject, wrong endpoint/region resolving to a different bucket namespace, the object deleted between IsObjectExist and GetObject, transient OSS gateway/network error, or SDK retry exhaustion.","commonSituations":"STS token expired mid-CI run; AccessKey scoped without oss:GetObject on the bucket policy; endpoint set to the wrong region so the key namespace mismatches; corporate proxy dropping the HTTPS connection; OSS regional incident.","solutions":["Wait a minute and re-run the Terraform command (transient OSS/network blips are common and the Get path is not internally retried for this error).","Refresh credentials: re-issue the STS token or verify ALICLOUD_ACCESS_KEY_ID / ALICLOUD_ACCESS_KEY_SECRET are correct and not expired.","Confirm the RAM/IAM principal has oss:GetObject (and oss:ListObjects) on the bucket via the Aliyun console or policy simulator.","Double-check bucket, endpoint and region in the backend config match where the state object actually lives.","Check Alibaba Cloud OSS status page for a regional outage if the error persists across retries."],"exampleFix":"// before: wrong region/endpoint -> object not reachable\n// terraform init -backend-config=\"endpoint=oss-cn-beijing.aliyuncs.com\"\n\n// after: endpoint matches the bucket's region\n// terraform init -backend-config=\"endpoint=oss-cn-hangzhou.aliyuncs.com\"","handlingStrategy":"retry","validationCode":"// Pre-flight: confirm the state object is reachable before relying on Get\n// ctx := context.Background()\n// exists, err := bucket.IsObjectExist(stateFile)\n// if err != nil { /* log + abort init */ }\n// if !exists { /* first-run, no state yet */ }","typeGuard":null,"tryCatchPattern":"// OSS GetObject failures are mostly transient; retry with backoff\n// var lastErr error\n// for i := 0; i < 3; i++ {\n//   payload, diags := client.Get()\n//   if !diags.HasErrors() { return payload }\n//   lastErr = diags.Err()\n//   time.Sleep(time.Duration(1<<i) * time.Second)\n// }\n// return lastErr","preventionTips":["Keep STS/AccessKey credentials well within their expiry for the whole CI run.","Grant oss:GetObject + oss:ListObjects to the principal in the bucket policy.","Pin the correct endpoint/region matching the bucket.","Run Terraform from a host with a stable link to the OSS region."],"tags":["oss","alibaba-cloud","network","remote-state","credentials"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}