Repository navigation
[fix][broker] Decode topic name in the scalable topic migrate endpoint - #26711
Merged
merlimat merged 1 commit intoSep 29, 2026
Merged
Conversation
migrateToScalable spliced the @encoded path segment straight into the scalable and persistent topic identities, unlike its sibling createScalableTopic, which URL-decodes it first. For any local name containing a character the admin client percent-encodes in the REST path (space, non-ASCII, ...), every identity the endpoint derived was wrong: - Migrating "a b" checked existence of persistent://t/ns/a%20b, so the request 404ed even though the topic exists. - If a topic literally named like the encoded spelling existed, the endpoint would authorize, existence-check, and terminate that other topic instead, and write the scalable record under an identity no V5 lookup ever derives: clients resolve the scalable identity from the raw local name (TopicName#toScalableTopic), so the migrated record would be invisible to them and to the PIP-475 recreate guard. Decode the segment with Codec.decode before building the names, exactly as the create path does.
merlimat
approved these changes
Sep 29, 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.
Motivation
The scalable-topic migrate endpoint (
POST .../persistent/{tenant}/{namespace}/{topic}/migrateToScalable) declares its{topic}path segment@Encodedbut spliced it straight into the derived topic identities without URL-decoding — unlike its siblingcreateScalableTopic, which callsCodec.decodefirst. For any local name containing a character the admin client percent-encodes in the REST path (a space, a non-ASCII character, …), every identity the endpoint derived was wrong:a bchecked existence ofpersistent://t/ns/a%20b, so the request 404s ("Topic does not exist") even though the topic exists.topic://t/ns/a%20b— an identity no v5 client lookup ever derives (clients resolve the scalable identity from the raw local name viaTopicName#toScalableTopic), so the migrated record is invisible to clients and to the PIP-475 recreate guard.Modifications
Decode the
@Encodedsegment withCodec.decodebefore building the topic names, exactly ascreateScalableTopicalready does. AddedScalableTopicsMigrateTest, which drives the endpoint with a mocked pipeline and asserts the authorization target, the metadata-lookup name, and the existence-check name all use the decoded local name (a%20b→a b,caf%C3%A9→café).This is the migrate write-path; the read-side endpoints in the same resource share the same missing-decode and would be coherent follow-ups.
Verifying this change
Covered by the added unit test
ScalableTopicsMigrateTest. It fails without the fix (expected [persistent://tenant/ns/a b] but found [persistent://tenant/ns/a%20b]) and passes with it.Found by code inspection while working on the related
TopicName#toScalableTopicidentity fix (#26668).Does this pull request potentially affect one of the following parts:
Documentation
doc-not-needed