PBM-1472 sanitize double slashes in storage config parts#1268
PBM-1472 sanitize double slashes in storage config parts#1268jcechace wants to merge 6 commits intopercona:devfrom
Conversation
Add storage.TrimSlashes() helper to strip leading/trailing '/' from bucket, prefix, and container config values. Extra slashes in these values cause S3 signature errors and backup discovery failures because none of the storage SDKs sanitize these inputs.
Trim leading/trailing slashes from Bucket and Prefix in s3.Config.Cast(). Add TestCastSlashTrimming tests.
Trim leading/trailing slashes from Bucket and Prefix in mio.Config.Cast(). Add TestCastSlashTrimming tests.
Trim leading/trailing slashes from Bucket and Prefix in gcs.Config.Cast(). Add TestCastSlashTrimming tests.
Trim leading/trailing slashes from Container and Prefix in azure.Config.Cast(). Add TestCastSlashTrimming tests.
Trim leading/trailing slashes from Bucket and Prefix in oss.Config.Cast(). Add TestCastSlashTrimming tests.
|
@boris-ilijic sanitizing in
PBM will still work fine (as pbm backup
Starting backup "2026-02-17T12:14:35Z"....Backup "2026-02-17T12:14:35Z" saved to remote store (path: "http://minio:9000/bcp//pbme2etest")
pbm status
Main storage:
Type: S3
Region: us-east-1
Path: http://minio:9000/bcp//pbme2etestHere A fix for if strings.HasSuffix(key, ".bucket") || strings.HasSuffix(key, ".container") || strings.HasSuffix(key, ".prefix") {
s := strings.Trim(v.(string), "/")
}which seems a bit fragile -- but that is the case for the entire function |
|
It's better to avoid having invalid config setting (eg. t1/ in example) and then mutate it all the time before the usage. That will be potential source of bugs, so that needs to be fixed. That check doesn't need to be fragile, it can be just case like existing one: percona-backup-mongodb/pbm/config/config.go Lines 624 to 627 in 01eb998 Optionally:
So something like this: |
But overall I agree that this shouldn't likely be in Cast(). Will change that part |
While you are changing, it should be clearer and easier to report the error than to sanitize. |
Sorry I missed your comment, it's hidden by formatting in gray, see it above. |
Ticket: https://perconadev.atlassian.net/browse/PBM-1472