fix: don't URL-encode V2 continuation tokens under encoding-type=url#91
Merged
ServerSideHannes merged 2 commits intoJun 30, 2026
Merged
Conversation
ListObjectsV2 continuation tokens are opaque cursors, not keys. Per the
S3 spec, encoding-type=url only encodes Key/Prefix/Delimiter/StartAfter,
and botocore never URL-decodes the continuation token. The V2 serializer
ran NextContinuationToken / ContinuationToken through _encode_key(), so
under encoding-type=url a key-shaped backend token like
'production-v3/production/base/.../data_0007.tar' became
'...%2F...data_0007.tar'. That mangled token can't round-trip: the
backend never advances, the same page (and token) repeats, and botocore's
paginator aborts with 'The same next token was received twice' — which
wedged CNPG barman-cloud base backups and retention on large catalogs.
Emit V2 continuation tokens XML-escaped only, regardless of encoding_type.
Keys remain URL-encoded under encoding-type=url. The handler already
documented this intent ('opaque and must be passed back unchanged'); the
serializer violated it.
This was referenced Jun 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
CNPG
barman-cloudbase backups and retention enforcement against buckets fronted by this proxy fail with:This wedges Postgres base backups (stuck "starting up") and retention once a backup catalog grows past a single ListObjectsV2 page (~1000 keys). WAL archiving (
PUT) is unaffected because it doesn't paginate.Root cause
ListObjectsV2 continuation tokens are opaque cursors, not keys. Per the S3 spec,
encoding-type=urlonly URL-encodesKey,Prefix,Delimiter, andStartAfter— not the continuation token — and botocore never URL-decodes it.barman/botocore send
encoding-type=url. The V2 serializer ranNextContinuationToken/ContinuationTokenthrough_encode_key(..., encoding_type), so a key-shaped backend token likeproduction-v3/production/base/.../data_0007.tarwas emitted as…%2F…data_0007.tar. That token can't round-trip: the proxy decodes one layer, the backend doesn't recognize it, returns the same first page, and the identical token repeats → botocore's paginator aborts.The handler already documented the correct behaviour (
# V2 continuation tokens are opaque and must be passed back unchanged); only the serializer violated it.Fix
Emit V2
NextContinuationToken/ContinuationTokenXML-escaped only, regardless ofencoding_type. Object keys remain URL-encoded underencoding-type=url.Test
tests/unit/test_list_objects_continuation_token.pyreproduces the loop: pre-fix the token comes back%2F-encoded (asserted failure), post-fix it's verbatim, and keys are still URL-encoded. Full unit suite green (539 passed).Separate from #88 (Py2
exceptsyntax + parallel list HEAD fan-out); this is the actual pagination-loop fix.