{"record":{"id":"3ccdc8dd8004e45f","repo":"hashicorp/terraform","slug":"error-getting-bucket-v-3ccdc8","errorCode":null,"errorMessage":"error getting bucket: %#v","messagePattern":"error getting bucket: %#v","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/backend/remote-state/oss/client.go","lineNumber":104,"sourceCode":"\t\t\tif time.Now().Before(deadline) {\n\t\t\t\ttime.Sleep(consistencyRetryPollInterval)\n\t\t\t\tlog.Println(\"[INFO] retrying OSS RemoteClient.Get...\")\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\treturn nil, diags.Append(fmt.Errorf(errBadChecksumFmt, digest))\n\t\t}\n\n\t\tbreak\n\t}\n\treturn payload, diags\n}\n\nfunc (c *RemoteClient) Put(data []byte) tfdiags.Diagnostics {\n\tvar diags tfdiags.Diagnostics\n\tbucket, err := c.ossClient.Bucket(c.bucketName)\n\tif err != nil {\n\t\treturn diags.Append(fmt.Errorf(\"error getting bucket: %#v\", err))\n\t}\n\n\tbody := bytes.NewReader(data)\n\n\tvar options []oss.Option\n\tif c.acl != \"\" {\n\t\toptions = append(options, oss.ACL(oss.ACLType(c.acl)))\n\t}\n\toptions = append(options, oss.ContentType(\"application/json\"))\n\tif c.serverSideEncryption {\n\t\toptions = append(options, oss.ServerSideEncryption(\"AES256\"))\n\t}\n\toptions = append(options, oss.ContentLength(int64(len(data))))\n\n\tif body != nil {\n\t\tif err := bucket.PutObject(c.stateFile, body, options...); err != nil {\n\t\t\treturn diags.Append(fmt.Errorf(\"failed to upload state %s: %#v\", c.stateFile, err))\n\t\t}","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/backend/remote-state/oss/client.go#L86-L122","documentation":"In RemoteClient.Put() (client.go:102-104), ossClient.Bucket(c.bucketName) failed. Like error 344, Bucket() is a local name-validation constructor; failure means the bucket name is invalid. This blocks every state write (terraform apply/refresh).","triggerScenarios":"Put() called during state persistence with a bucketName failing OSS naming rules (uppercase, underscore, bad length, illegal chars). No network call is attempted.","commonSituations":"Bucket attribute was changed to an invalid name after init; interpolation produced an invalid value; copy-paste of a non-normalized bucket name.","solutions":["Correct the bucket name to lowercase letters, digits, and hyphens only (3-63 chars).","Re-run terraform init after fixing the backend block so the client is rebuilt with the valid name.","Check the variable/local feeding bucket for stray characters or empty values."],"exampleFix":"// before\nbackend \"oss\" {\n  bucket = \"TF_State_Bucket\"\n}\n\n// after\nbackend \"oss\" {\n  bucket = \"tf-state-bucket\"\n}","handlingStrategy":"validation","validationCode":"// Reuse the OSS bucket-name validator from error 344 before any Put path.\nif !validBucketName(c.bucketName) {\n    return fmt.Errorf(\"refusing Put: invalid bucket %q\", c.bucketName)\n}","typeGuard":null,"tryCatchPattern":"// Local validation; not retryable. Fix the name and re-init.\nif err != nil && strings.Contains(err.Error(), \"error getting bucket\") {\n    return fixBucketName(err)\n}","preventionTips":["Keep bucket names valid from day one; see error 344 validator.","Re-run terraform init whenever the backend block changes.","Lint backend config in CI."],"tags":["alibaba-cloud","oss","bucket-validation","remote-state","go"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}