{"record":{"id":"41420ac8ee41d30f","repo":"apache/beam","slug":"error-parsing-s3-destination-uri-s-v","errorCode":null,"errorMessage":"error parsing S3 destination uri %s: %v","messagePattern":"error parsing S3 destination uri (.+?): (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/io/filesystem/s3/s3.go","lineNumber":218,"sourceCode":"\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\n}\n\n// Compile time check for interface implementations.\nvar (\n\t_ filesystem.LastModifiedGetter = (*fs)(nil)\n\t_ filesystem.Remover            = (*fs)(nil)","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/io/filesystem/s3/s3.go#L200-L236","documentation":"Returned by fs.Copy when the DESTINATION path (newpath) cannot be parsed as a valid S3 URI. parseURI requires an s3://bucket/key form; invalid schemes or missing components are rejected before CopyObject is invoked.","triggerScenarios":"Calling fs.Copy with a newpath that is not a valid S3 URI (wrong scheme, missing bucket, or empty key).","commonSituations":"Constructing destination names by string concatenation that omit the s3:// prefix; empty destination variables; Windows-style paths used as destinations.","solutions":["Check that newpath is a well-formed s3://bucket/key URI.","Fix destination-name construction so bucket and key are always present.","Validate both source and destination URIs before calling Copy."],"exampleFix":"// before\ndest := bucket + \"/\" + key // no scheme\nfsys.Copy(ctx, src, dest)\n\n// after\ndest := \"s3://\" + bucket + \"/\" + key\nfsys.Copy(ctx, src, dest)","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(newpath); err != nil { return fmt.Errorf(\"copy destination invalid: %w\", err) }\nif err := fsys.Copy(ctx, oldpath, newpath); err != nil { return err }","preventionTips":["Build destination names with fmt.Sprintf(\"s3://%s/%s\", bucket, key) instead of raw concatenation.","Check for empty destination variables before calling Copy.","Add tests asserting generated destinations always carry the s3:// scheme."],"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"}