{"record":{"id":"1a8cdf1621d4f67b","repo":"apache/beam","slug":"error-parsing-s3-source-uri-s-v","errorCode":null,"errorMessage":"error parsing S3 source uri %s: %v","messagePattern":"error parsing S3 source uri (.+?): (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/io/filesystem/s3/s3.go","lineNumber":212,"sourceCode":"\t\treturn fmt.Errorf(\"error parsing S3 uri %s: %v\", filename, err)\n\t}\n\n\tparams := &s3.DeleteObjectInput{\n\t\tBucket: aws.String(bucket),\n\t\tKey:    aws.String(key),\n\t}\n\tif _, err = f.client.DeleteObject(ctx, params); err != nil {\n\t\treturn fmt.Errorf(\"error deleting object %s: %v\", filename, err)\n\t}\n\n\treturn nil\n}\n\n// Copy copies the file from the old path to the new path.\nfunc (f *fs) Copy(ctx context.Context, oldpath, newpath string) error {\n\tsourceBucket, sourceKey, err := parseURI(oldpath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error parsing S3 source uri %s: %v\", oldpath, err)\n\t}\n\n\tcopySource := fmt.Sprintf(\"%s/%s\", sourceBucket, sourceKey)\n\tdestBucket, destKey, err := parseURI(newpath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error parsing S3 destination uri %s: %v\", newpath, err)\n\t}\n\n\tparams := &s3.CopyObjectInput{\n\t\tBucket:     aws.String(destBucket),\n\t\tCopySource: aws.String(copySource),\n\t\tKey:        aws.String(destKey),\n\t}\n\tif _, err = f.client.CopyObject(ctx, params); err != nil {\n\t\treturn fmt.Errorf(\"error copying object %s: %v\", oldpath, err)\n\t}\n\n\treturn nil","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/io/filesystem/s3/s3.go#L194-L230","documentation":"Returned by fs.Copy when the SOURCE path (oldpath) cannot be parsed as a valid S3 URI. parseURI requires an s3://bucket/key form; invalid schemes or missing components are rejected before the copy operation.","triggerScenarios":"Calling fs.Copy(ctx, oldpath, newpath) where oldpath is not a valid S3 URI (e.g. \"s3:/bucket/key\", local path, or \"s3://\" with empty bucket/key).","commonSituations":"Copy jobs mixing local and s3 paths; string formatting bugs producing malformed URIs; copying from GCS into S3 through the S3 filesystem.","solutions":["Check that oldpath is a well-formed s3://bucket/key URI.","Fix path-building code that drops or duplicates the scheme or slashes.","Use the appropriate filesystem for non-S3 sources instead of fs.Copy."],"exampleFix":"// before\nfsys.Copy(ctx, \"bucket/key\", \"s3://bucket/key2\") // missing scheme\n\n// after\nsrc, dst := \"s3://bucket/key\", \"s3://bucket/key2\"\nif _, _, err := parseURIPublic(src); err != nil { return fmt.Errorf(\"bad source %q: %w\", src, err) }\nfsys.Copy(ctx, src, dst)","handlingStrategy":"validation","validationCode":"func validS3URI(p string) error {\n    if !strings.HasPrefix(p, \"s3://\") { return fmt.Errorf(\"missing s3:// scheme: %q\", p) }\n    rest := strings.TrimPrefix(p, \"s3://\")\n    bucket, key, ok := strings.Cut(rest, \"/\")\n    if !ok || bucket == \"\" || key == \"\" { return fmt.Errorf(\"need s3://bucket/key, got %q\", p) }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if err := validS3URI(oldpath); err != nil { return fmt.Errorf(\"copy source invalid: %w\", err) }\nif err := fsys.Copy(ctx, oldpath, newpath); err != nil { return err }","preventionTips":["Validate both source and destination URIs before initiating a copy.","Normalize paths through a single URI builder function.","Reject local or other-cloud paths early with a clear message."],"tags":["aws","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"}