{"record":{"id":"05d19858388890f5","repo":"apache/beam","slug":"error-getting-object-s-v","errorCode":null,"errorMessage":"error getting object %s: %v","messagePattern":"error getting object (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/io/filesystem/s3/s3.go","lineNumber":131,"sourceCode":"\n\treturn objects, nil\n}\n\n// OpenRead returns a new io.ReadCloser to read contents from the file. The caller must call Close\n// on the returned io.ReadCloser when done reading.\nfunc (f *fs) OpenRead(ctx context.Context, filename string) (io.ReadCloser, error) {\n\tbucket, key, err := parseURI(filename)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error parsing S3 uri %s: %v\", filename, err)\n\t}\n\n\tparams := &s3.GetObjectInput{\n\t\tBucket: aws.String(bucket),\n\t\tKey:    aws.String(key),\n\t}\n\toutput, err := f.client.GetObject(ctx, params)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error getting object %s: %v\", filename, err)\n\t}\n\n\treturn output.Body, nil\n}\n\n// OpenWrite returns a new io.WriteCloser to write contents to the file. The caller must call Close\n// on the returned io.WriteCloser when done writing.\nfunc (f *fs) OpenWrite(ctx context.Context, filename string) (io.WriteCloser, error) {\n\tbucket, key, err := parseURI(filename)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error parsing S3 uri %s: %v\", filename, err)\n\t}\n\n\treturn newWriter(ctx, f.client, bucket, key), nil\n}\n\n// Size returns the size of the file.\nfunc (f *fs) Size(ctx context.Context, filename string) (int64, error) {","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/io/filesystem/s3/s3.go#L113-L149","documentation":"OpenRead wraps a failed s3.GetObject call with this message. The URI parsed fine, but retrieving the object body failed — most often the object doesn't exist (NoSuchKey), the bucket is missing (NoSuchBucket), or access is denied. The filename and underlying AWS error are embedded in the message.","triggerScenarios":"Calling OpenRead on s3://bucket/key where the key does not exist, the bucket doesn't exist or is in the wrong region, credentials lack s3:GetObject, or the request fails at the network level.","commonSituations":"Upstream job wrote to a different key than expected; case-sensitivity mismatch in key names; stale assumed-role credentials; reading a file deleted by another pipeline stage.","solutions":["Verify the object exists (aws s3 ls s3://bucket/key or HeadObject) before/when reading.","Check that the key spelling and case exactly match the stored object.","Grant s3:GetObject on the object prefix to the caller's IAM identity.","Handle smithy http.StatusNotFound / NoSuchKey in the wrapped error to produce a clearer message."],"exampleFix":"// before\nr, err := fs.OpenRead(ctx, \"s3://b/key\")\n// after\nvar ae smithy.APIError\nr, err := fs.OpenRead(ctx, \"s3://b/key\")\nif errors.As(err, &ae) && ae.ErrorCode() == \"NotFound\" {\n  return fmt.Errorf(\"object s3://b/key does not exist: %w\", err)\n}","handlingStrategy":"try-catch","validationCode":"// existence check before read\nif _, err := f.client.HeadObject(ctx, &s3.HeadObjectInput{Bucket: aws.String(b), Key: aws.String(k)}); err != nil {\n  return fmt.Errorf(\"object s3://%s/%s not readable: %w\", b, k, err)\n}","typeGuard":null,"tryCatchPattern":"r, err := fs.OpenRead(ctx, uri)\nif err != nil {\n  var ae smithy.APIError\n  if errors.As(err, &ae) && (ae.ErrorCode() == \"NotFound\" || ae.ErrorCode() == \"NoSuchKey\") {\n    return fmt.Errorf(\"missing object %s\", uri) // handle explicitly\n  }\n  return fmt.Errorf(\"read %s failed: %w\", uri, err)\n}","preventionTips":["HeadObject the key before reading when existence is uncertain.","Remember S3 keys are case-sensitive and exact.","Grant s3:GetObject on the prefix in IAM.","Distinguish NotFound from transient errors to decide retry vs fail."],"tags":["aws","s3","network","file-read"],"backgroundTag":"resource-not-found","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}