Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] [broker] No longer allow creating subscription that contains slash #23594

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

poorbarcode
Copy link
Contributor

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

No longer allow creating a subscription that contains a slash

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-not-needed Your PR changes do not impact docs ready-to-test release/3.0.10 release/3.3.4 release/4.0.1 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.

9 participants