Skip to content

[fix][broker] URL-encode sub-name in Txn pending-ack topic #25727

Merged
shibd merged 1 commit intoapache:masterfrom
shibd:fix_slash_sub_pending_ack
May 9, 2026
Merged

[fix][broker] URL-encode sub-name in Txn pending-ack topic #25727
shibd merged 1 commit intoapache:masterfrom
shibd:fix_slash_sub_pending_ack

Conversation

@shibd
Copy link
Copy Markdown
Member

@shibd shibd commented May 9, 2026

Motivation

When a subscription name contains / (e.g. a Pulsar Function's fully-qualified name like tenant/namespace/function), opening the transaction pending-ack store fails with:

Root cause: MLPendingAckStore.getTransactionPendingAckStoreSuffix() appends the raw subscription name to the topic name string. When the result is passed to TopicName.get(), the extra / characters produce four path segments, which TopicName misidentifies as a deprecated V1 (cluster-scoped) name and throws synchronously.

Changes

  • MLPendingAckStore.getTransactionPendingAckStoreSuffix(): URL-encode the subscription name with Codec.encode() before appending it. TopicName always Codec.decode()s the local-name on parse and re-encodes it on output (getPersistenceNamingEncoding()), so there is no double-encoding and the managed-ledger path is correct.
  • PersistentTopic.unsubscribe(): Remove the pre-emptive Codec.encode() call — encoding is now done centrally in getTransactionPendingAckStoreSuffix().
  • Tests: Two new assertions — one verifying slash-containing subscription names work correctly, one as a regression guard for normal names.

Verifying this change

All tests passed

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

…pport '/' in sub names

Subscription names containing '/' caused TopicName.get() to throw
IllegalArgumentException ("V1 topic names are no longer supported")
when opening the transaction pending-ack store, because the extra
slashes created four path segments instead of three.

Fix: URL-encode the subscription name in
MLPendingAckStore.getTransactionPendingAckStoreSuffix() before
appending it to the topic name. TopicName always Codec.decode()s
the local-name on parse and re-encodes it on output, so there is
no double-encoding. Also remove the pre-emptive Codec.encode() call
in PersistentTopic.unsubscribe() that was added as a workaround.
@shibd shibd self-assigned this May 9, 2026
@shibd shibd added type/bug The PR fixed a bug or issue reported a bug cherry-picked/branch-4.2 labels May 9, 2026
@shibd shibd changed the title [fix][broker] URL-encode subscription name in pending-ack topic to su… [fix][broker] URL-encode sub-name in Txn pending-ack topic May 9, 2026
@shibd shibd merged commit 4e2df4e into apache:master May 9, 2026
82 of 84 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-picked/branch-4.2 type/bug The PR fixed a bug or issue reported a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants