{"record":{"id":"01cd26d111d556e0","repo":"apache/beam","slug":"error-parsing-s3-uri-s-v","errorCode":null,"errorMessage":"error parsing S3 uri %s: %v","messagePattern":"error parsing S3 uri (.+?): (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/io/filesystem/s3/s3.go","lineNumber":122,"sourceCode":"\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"invalid key pattern: %s\", keyPattern)\n\t\t\t}\n\n\t\t\tif match {\n\t\t\t\tobjects = append(objects, key)\n\t\t\t}\n\t\t}\n\t}\n\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)","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/io/filesystem/s3/s3.go#L104-L140","documentation":"OpenRead parses the filename as an S3 URI before downloading; this error wraps a parseURI failure. It means the filename string is not a valid s3://bucket/key URI. The offending filename and underlying parse error are both included in the message.","triggerScenarios":"Calling OpenRead with a filename lacking the s3:// scheme, with an empty bucket or key, or otherwise malformed (e.g. 's3:///no-key', 'gs://bucket/obj', or a local path).","commonSituations":"Mixing up filesystem providers (passing GCS or local paths to the S3 filesystem); a resource name missing its scheme after path joining; typos in 's3://' prefix.","solutions":["Pass a well-formed URI of the form s3://bucket/key.","Check which filesystem provider the pipeline resolved for this path — use the matching one.","Normalize/validate the filename before calling OpenRead (see validation code).","Inspect the wrapped parse error to see which URI component failed."],"exampleFix":"// before\nr, err := fs.OpenRead(ctx, \"/data/file.txt\")\n// after\nr, err := fs.OpenRead(ctx, \"s3://my-bucket/data/file.txt\")","handlingStrategy":"validation","validationCode":"func validS3URI(name string) bool {\n  u, err := url.Parse(name)\n  return err == nil && u.Scheme == \"s3\" && u.Host != \"\" && strings.TrimPrefix(u.Path, \"/\") != \"\"\n}","typeGuard":null,"tryCatchPattern":"r, err := fs.OpenRead(ctx, filename)\nif err != nil {\n  if strings.Contains(err.Error(), \"error parsing S3 uri\") {\n    return fmt.Errorf(\"bad S3 path %q, expected s3://bucket/key\", filename)\n  }\n  return fmt.Errorf(\"open failed: %w\", err)\n}","preventionTips":["Always include the s3:// scheme and non-empty bucket and key.","Don't pass local or gs:// paths to the S3 filesystem.","Validate URIs at config-load time, not at read time.","Centralize path construction in one helper that guarantees scheme+bucket+key."],"tags":["s3","url","validation"],"backgroundTag":"invalid-url-format","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}