Skip to content

PIP-242: Topic name restrictions #19239

Open

Description

@mattisonchao

Motivation

Currently, the Apache Pulsar has no restrictions on the topic name. For example, we allowed users to create topic with -partition- keyword, which is confusing for our developers to identify whether this is a partition of a partitioned topic. Plus, we need to add more logic to be compatible with this special topic name. for example:

Goal

This proposal aimed to add more restrictions for a topic name. that includes three parts as follows:

  1. Using NamedEntity to validate the topic name characters.
  2. Make the -partition- string the keyword. That allows the user to use it when it's a partitioned topic.

Create a topic:
no corresponding partitioned topic

  • persistent://public/default/local-name (passed)
  • persistent://public/default/local-name-partition-z (rejected by keyword)
  • persistent://public/default/local-name-partition-0 (rejected by keyword)

Has corresponding partitioned topic, partitions=2 and topic partition name is persistent://public/default/local-name

  • persistent://public/default/local-name-partition-0 (passed, Because it is the partition topic's sub-partition)
  • persistent://public/default/local-name-partition-z (rejected by keyword)
  • persistent://public/default/local-name-partition-4 (rejected, Because it exceeds the number of maximum partitions)

Create a partitioned topic(topic metadata)

  • persistent://public/default/local-name (passed)
  • persistent://public/default/local-name-partition-z (rejected by keyword)
  • persistent://public/default/local-name-partition-0 (rejected by keyword)

Compatibility

We will introduce the new configuration strictTopicNameEnabled to support compatibility. Users can easily disable it to get rid of the restrictions.

API Changes

Add a new configuration, strictTopicNameEnabled=false.

Implementation

  1. Add configuration strictTopicNameEnabled=false and make it dynamic.
  2. Add topic name validation by NamedEntity
  3. Add partitioned topic rejection logic.
  4. Add warning logs to inform users that we do not recommend creating topics that name with the restrictions name when users disable enableStrictTopicName.
  5. Make strictTopicNameEnabled=true in the next major release. and mark that this config will be removed in the future.

Activity

  1. changed the title [-]PIP-242: Introduce `enableStrictMode` to reject creating topic with `-partition-` keyword.[/-] [+][WIP]PIP-242: Introduce `enableStrictMode` to reject creating topic with `-partition-` keyword.[/+] on Jan 16, 2023
  2. self-assigned this
    on Jan 16, 2023
  3. changed the title [-][WIP]PIP-242: Introduce `enableStrictMode` to reject creating topic with `-partition-` keyword.[/-] [+][WIP]PIP-242: Introduce `enableStrictTopicName` to reject creating topic with `-partition-` keyword.[/+] on Jan 28, 2023
  4. changed the title [-][WIP]PIP-242: Introduce `enableStrictTopicName` to reject creating topic with `-partition-` keyword.[/-] [+]PIP-242: Introduce `enableStrictTopicName` to reject creating topic with `-partition-` keyword.[/+] on Jan 28, 2023
  5. changed the title [-]PIP-242: Introduce `enableStrictTopicName` to reject creating topic with `-partition-` keyword.[/-] [+]PIP-242: Introduce "enableStrictTopicName" configuration to enable topic name restriction.[/+] on Feb 1, 2023
  6. changed the title [-]PIP-242: Introduce "enableStrictTopicName" configuration to enable topic name restriction.[/-] [+]PIP-242: Topic Name restrictions[/+] on Feb 11, 2023
  7. changed the title [-]PIP-242: Topic Name restrictions[/-] [+]PIP-242: Topic name restrictions[/+] on Feb 11, 2023
  8. github-actions commented on Mar 24, 2023

    @github-actions

    The issue had no activity for 30 days, mark with Stale label.

  9. modified the milestones: 3.0.0, 3.1.0 on Apr 13, 2023
  10. pgier commented on May 5, 2023

    @pgier
    Contributor

    Recent bug related to quotes in topic names: #20230

  11. github-actions commented on Jun 5, 2023

    @github-actions

    The issue had no activity for 30 days, mark with Stale label.

  12. tisonkun commented on Jun 13, 2023

    @tisonkun
    Member

    May I ask what is the status of this PIP? Did it get accepted? What's the subtasks to be implemented that we can conclude this PIP gets done.

  13. github-actions commented on Jul 14, 2023

    @github-actions

    The issue had no activity for 30 days, mark with Stale label.

  14. added
    category/reliability
    on Sep 11, 2023
  15. merlimat commented on Oct 24, 2026

    @merlimat
    Contributor

    Status update: PIP-242 passed its vote (https://lists.apache.org/thread/34y7x979zztns2htspn7v3c079cdzh8f), but only part 1 (#19582) landed. It adds the strictTopicNameEnabled setting, which nothing in the broker reads yet. Still missing: validating topic-name characters with NamedEntity, rejecting the -partition- keyword for non-partition topics when the flag is on, and the warning logs from the proposal. Keeping this open. Anyone interested is welcome to pick up the remaining parts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Stalecategory/reliabilitytype/PIP

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions