Skip to content

Conversation

@ChimdumebiNebolisa
Copy link

@ChimdumebiNebolisa ChimdumebiNebolisa commented Jan 19, 2026

Fixes #24998

Motivation

The current namespace autoTopicCreation override validation rejects defaultNumPartitions when topicType=non-partitioned. This forces clients and IaC tooling to conditionally omit a field based on topic type, which makes the API less consistent and more error-prone.

Modifications

  • Relaxed AutoTopicCreationOverride validation to allow defaultNumPartitions to be set when topicType=non-partitioned (value is accepted and persisted).
  • Kept runtime behavior unchanged: defaultNumPartitions is still only used for partitioned auto-creation.
  • Updated unit test expectations and added a broker test to verify the value is ignored during non-partitioned topic creation.

Verifying this change

This change added tests and can be verified as follows:

  • mvn -pl pulsar-common -Dtest=AutoTopicCreationOverrideTest test
  • mvn -pl pulsar-broker -am -Dtest=AdminApi2Test#testAutoTopicCreationOverrideNonPartitionedDefaultNumPartitionsIgnored -Dsurefire.failIfNoSpecifiedTests=false test

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

  • 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

Documentation

  • doc-not-needed

Note: Updated validateOverride to preserve topic type validation and allow defaultNumPartitions for NON_PARTITIONED topics only when the value is null, 0, or 1. Updated unit tests to cover 0, 1, and to reject 2.

@ChimdumebiNebolisa ChimdumebiNebolisa force-pushed the fix-24998-allow-defaultNumPartitions branch from 6a10c6a to 7a13f42 Compare January 19, 2026 13:19
@ChimdumebiNebolisa
Copy link
Author

Updated validateOverride to keep topic type validation and allow defaultNumPartitions for NON_PARTITIONED only when null, 0, or 1. Updated unit tests to cover 0, 1, and reject 2.

@lhotari lhotari changed the title [fix][admin] Allow defaultNumPartitions for non-partitioned autoTopicCreation override (Fixes #24998) [fix][admin] Allow defaultNumPartitions for non-partitioned autoTopicCreation override Jan 20, 2026
@lhotari
Copy link
Member

lhotari commented Jan 20, 2026

Updated validateOverride to keep topic type validation and allow defaultNumPartitions for NON_PARTITIONED only when null, 0, or 1. Updated unit tests to cover 0, 1, and reject 2.

Please add this information to the PR description.

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, thanks for the contribution @ChimdumebiNebolisa

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 release/4.0.9 release/4.1.3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API usability: defaultNumPartitions validation is too strict for non-partitioned topic type

2 participants