{"record":{"id":"fd0db3d88c4ddc4f","repo":"apache/beam","slug":"error-parsing-s3-uri-v","errorCode":null,"errorMessage":"error parsing S3 uri: %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":61,"sourceCode":"\tcfg, err := config.LoadDefaultConfig(ctx)\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"error loading AWS config: %v\", err))\n\t}\n\n\tclient := s3.NewFromConfig(cfg)\n\treturn &fs{client: client}\n}\n\n// Close closes the filesystem.\nfunc (f *fs) Close() error {\n\treturn nil\n}\n\n// List returns a slice of the files in the filesystem that match the glob pattern.\nfunc (f *fs) List(ctx context.Context, glob string) ([]string, error) {\n\tbucket, keyPattern, err := parseURI(glob)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error parsing S3 uri: %v\", err)\n\t}\n\n\tkeys, err := f.listObjectKeys(ctx, bucket, keyPattern)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error listing object keys: %v\", err)\n\t}\n\n\tif len(keys) == 0 {\n\t\treturn nil, nil\n\t}\n\n\turis := make([]string, len(keys))\n\tfor i, key := range keys {\n\t\turis[i] = makeURI(bucket, key)\n\t}\n\n\treturn uris, nil\n}","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/io/filesystem/s3/s3.go#L43-L79","documentation":"S3 List first parses the glob into a bucket and key pattern via parseURI; if the string is not a well-formed S3 URI (no bucket, bad scheme, unparseable form), the parse error is wrapped as 'error parsing S3 uri: %v'. The request never reaches AWS.","triggerScenarios":"Calling fs.List(ctx, glob) with a string that parseURI rejects — e.g. missing 's3://' scheme, empty bucket, or a path with no key component where one is required.","commonSituations":"Passing a plain path ('/data/file') or an HTTP URL instead of an s3:// URI; concatenating bucket and key incorrectly; config values with typos or stray whitespace.","solutions":["Ensure the glob starts with 's3://' and includes bucket and key pattern, e.g. 's3://bucket/prefix/*.json'.","Trim whitespace and validate the URI shape before calling List.","Fix the config/flag source producing the malformed URI.","Check the wrapped inner error to see exactly which URI component parseURI rejected."],"exampleFix":"// before\nfiles, err := fs.List(ctx, \"mybucket/data/*.json\") // missing scheme\n// after\nfiles, err := fs.List(ctx, \"s3://mybucket/data/*.json\")","handlingStrategy":"validation","validationCode":"func validS3URI(u string) bool {\n\trest, ok := strings.CutPrefix(u, \"s3://\")\n\tif !ok { return false }\n\tbucket, key, _ := strings.Cut(rest, \"/\")\n\treturn bucket != \"\" && key != \"\"\n}","typeGuard":null,"tryCatchPattern":"if _, err := fs.List(ctx, glob); err != nil && strings.Contains(err.Error(), \"error parsing S3 uri\") {\n\treturn fmt.Errorf(\"expected s3://bucket/key form, got %q: %w\", glob, err)\n}","preventionTips":["Always build S3 paths as s3://bucket/pattern.","Trim whitespace from config values before use.","Validate URIs at config-load time, not deep in the pipeline.","Don't pass plain paths or https URLs into the S3 filesystem."],"tags":["go","apache-beam","s3","uri","parsing"],"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-14T16:17:12.679Z"}