Skip to content

Conversation

@poorbarcode
Copy link
Contributor

@poorbarcode poorbarcode commented Nov 12, 2024

Motivation

Topic name rule

  • old version: {tenant}/{cluster}/{namespace}/{topic}/{subscription}
  • new version: {tenant}/{namespace}/{topic}/{subscription}

There are many HTTP APIs defined as HTTP Method {topic name}/{subscription name}

If a subscription contains /, the broker will assume it is a topic created with the old rule, then users will get a cluster does not exist error or a topic not found error

Modifications

Use the util method https://github.com/apache/pulsar/blob/master/pulsar-common/src/main/java/org/apache/pulsar/common/naming/NamedEntity.java to check new subscription name

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository: x

@poorbarcode poorbarcode added type/bug The PR fixed a bug or issue reported a bug release/3.3.3 release/3.0.8 release/4.0.1 labels Nov 12, 2024
@poorbarcode poorbarcode added this to the 4.1.0 milestone Nov 12, 2024
@poorbarcode poorbarcode self-assigned this Nov 12, 2024
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Nov 12, 2024
@Technoboy- Technoboy- closed this Nov 12, 2024
@Technoboy- Technoboy- reopened this Nov 12, 2024
@gaoran10
Copy link
Contributor

gaoran10 commented Nov 13, 2024

LGTM.

Do we need to support decoding URL-encoded subscription names in broker side? Thus users can use existing URL-encoded subscription names in HTTP requests.

zjxxzjwang

This comment was marked as resolved.

@zjxxzjwang
Copy link
Contributor

Can you put it into a method to facilitate the extension of more subscription name restrictions in the future

@Shawyeok
Copy link
Contributor

HTTP Method {topic name}/{subscription name}

The subscription name should be URL-encoded. For example, to create a subscription a/b for the topic persistent://public/default/topic1, the request should be:
PUT /admin/v2/persistent/public/default/topic1/subscription/a%252Fb.

I believe pulsar-admin and pulsarctl already handle this properly.

I appreciate the approach of restricting naming conventions for subscription and topic names. In my organization, subscription names are limited to the following characters: a-zA-Z0-9.-_.

@lhotari
Copy link
Member

lhotari commented Nov 21, 2024

Related PR: #23620

@lhotari
Copy link
Member

lhotari commented Nov 21, 2024

I appreciate the approach of restricting naming conventions for subscription and topic names. In my organization, subscription names are limited to the following characters: a-zA-Z0-9.-_.

@Shawyeok There's an enhancement issue #23614 created by @alpreu to add validation to subscription names.

Copy link
Member

@lhotari lhotari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like PR #23620 could be an effective way to prevent the auto creation of topics with slashes.

I think that we should consider implementing #23614 to validate subscription names instead of preventing the creation of subscription names with slashes.

As pointed out by @Shawyeok in #23594 (comment), if a slash is included in the subscription name, it should be url encoded. That's why this PR doesn't make sense to me and I'd prefer #23620 as the solution.

@poorbarcode
Copy link
Contributor Author

@lhotari

I think that we should consider implementing #23614 to validate subscription names instead of preventing the creation of subscription names with slashes.

But should we prevent the creation if the result of the validated subscription name is false?

Sent a discussion to do that

@lhotari
Copy link
Member

lhotari commented Nov 21, 2024

Sent a discussion to do that

@poorbarcode I think it makes sense to reference #23614 and #23620 in the discussion since those describe useful solutions. They are addressing 2 separate issues.

@poorbarcode poorbarcode force-pushed the fix/subscription_contains_slash branch from 6cf1439 to f74a42e Compare June 10, 2025 09:36
@poorbarcode
Copy link
Contributor Author

@lhotari

Used the util method https://github.com/apache/pulsar/blob/master/pulsar-common/src/main/java/org/apache/pulsar/common/naming/NamedEntity.java to check new subscription name, please take a look

Copy link
Member

@lhotari lhotari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@codecov-commenter
Copy link

codecov-commenter commented Jun 10, 2025

Codecov Report

Attention: Patch coverage is 84.61538% with 2 lines in your changes missing coverage. Please review.

Project coverage is 74.24%. Comparing base (bbc6224) to head (d9461e5).
Report is 1139 commits behind head on master.

Files with missing lines Patch % Lines
...pache/pulsar/broker/admin/v2/PersistentTopics.java 75.00% 0 Missing and 1 partial ⚠️
...va/org/apache/pulsar/broker/service/ServerCnx.java 80.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #23594      +/-   ##
============================================
+ Coverage     73.57%   74.24%   +0.66%     
- Complexity    32624    32685      +61     
============================================
  Files          1877     1868       -9     
  Lines        139502   145335    +5833     
  Branches      15299    16626    +1327     
============================================
+ Hits         102638   107900    +5262     
+ Misses        28908    28874      -34     
- Partials       7956     8561     +605     
Flag Coverage Δ
inttests 26.75% <46.15%> (+2.17%) ⬆️
systests 23.31% <46.15%> (-1.02%) ⬇️
unittests 73.73% <84.61%> (+0.89%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...org/apache/pulsar/broker/ServiceConfiguration.java 98.17% <100.00%> (-1.23%) ⬇️
...a/org/apache/pulsar/common/naming/NamedEntity.java 100.00% <100.00%> (+16.66%) ⬆️
...pache/pulsar/broker/admin/v2/PersistentTopics.java 88.51% <75.00%> (+7.57%) ⬆️
...va/org/apache/pulsar/broker/service/ServerCnx.java 72.16% <80.00%> (+0.01%) ⬆️

... and 1082 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@poorbarcode poorbarcode merged commit 7d54f40 into apache:master Jun 10, 2025
53 checks passed
@poorbarcode poorbarcode deleted the fix/subscription_contains_slash branch June 10, 2025 12:38
poorbarcode added a commit that referenced this pull request Jun 10, 2025
poorbarcode added a commit that referenced this pull request Jun 10, 2025
poorbarcode added a commit that referenced this pull request Jun 10, 2025
manas-ctds pushed a commit to datastax/pulsar that referenced this pull request Jun 12, 2025
…ash (apache#23594)

(cherry picked from commit 7d54f40)
(cherry picked from commit a27a375)
manas-ctds pushed a commit to datastax/pulsar that referenced this pull request Jun 12, 2025
…ash (apache#23594)

(cherry picked from commit 7d54f40)
(cherry picked from commit c28b59a)
manas-ctds pushed a commit to datastax/pulsar that referenced this pull request Jun 12, 2025
…ash (apache#23594)

(cherry picked from commit 7d54f40)
(cherry picked from commit c28b59a)
manas-ctds pushed a commit to datastax/pulsar that referenced this pull request Jun 12, 2025
…ash (apache#23594)

(cherry picked from commit 7d54f40)
(cherry picked from commit a27a375)
@ganesh-ctds ganesh-ctds mentioned this pull request Jun 12, 2025
4 tasks
manas-ctds pushed a commit to datastax/pulsar that referenced this pull request Jun 13, 2025
…ash (apache#23594)

(cherry picked from commit 7d54f40)
(cherry picked from commit a27a375)
manas-ctds pushed a commit to datastax/pulsar that referenced this pull request Jun 13, 2025
manas-ctds pushed a commit to datastax/pulsar that referenced this pull request Jun 14, 2025
…ash (apache#23594)

(cherry picked from commit 7d54f40)
(cherry picked from commit c28b59a)
(cherry picked from commit af2de4f)
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request Jun 16, 2025
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request Jun 16, 2025
…ash (apache#23594)

(cherry picked from commit 7d54f40)
(cherry picked from commit c28b59a)
(cherry picked from commit af2de4f)
nodece pushed a commit to nodece/pulsar that referenced this pull request Jun 18, 2025
KannarFr pushed a commit to CleverCloud/pulsar that referenced this pull request Sep 22, 2025
walkinggo pushed a commit to walkinggo/pulsar that referenced this pull request Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants