Skip to content

fix(group): allow zero retry settings on update - #4123

Merged
lizhimins merged 1 commit into
apache:rocketmq-studiofrom
zjncs:fix/group-settings-allow-zero-retry
Sep 9, 2026
Merged

lizhimins merged 1 commit into
apache:rocketmq-studiofrom
zjncs:fix/group-settings-allow-zero-retry

Conversation

@zjncs

@zjncs zjncs commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Motivation

UpdateConsumerGroupSettingsDTO validates both retry fields with @Positive:

@NotNull(message = "retryQueueNums is required")
@Positive(message = "retryQueueNums must be positive")
private Integer retryQueueNums;
@NotNull(message = "retryMaxTimes is required")
@Positive(message = "retryMaxTimes must be positive")
private Integer retryMaxTimes;

But 0 is a legitimate broker-side value — RocketMQAdminClientImpl forwards these straight into SubscriptionGroupConfig.setRetryQueueNums/setRetryMaxTimes, where retryQueueNums=0 disables retry queues and retryMaxTimes=0 sends failed messages directly to the DLQ. The sibling CreateConsumerGroupDTO already accepts it:

@PositiveOrZero(message = "retryMaxTimes must be zero or positive")
private Integer retryMaxTimes;

Concrete failure: a group created via POST /api/groups/create with retryMaxTimes: 0 (accepted) can never have its settings re-saved via the settings endpoint while keeping that value — the request fails bean validation with a 400 before reaching MetadataService.

Modifications

Both fields switch to @PositiveOrZero with matching messages, aligning the update path with the create path and the broker semantics. Negative values are still rejected.

Verification

New standalone UpdateConsumerGroupSettingsDTOTest (the controller test file is under review in another PR, so the validation is pinned in its own class, modeled on AlertRuleRequestDTOTest):

  • shouldAcceptZeroRetrySettingsTest — before the fix: fails with retryQueueNums must be positive / retryMaxTimes must be positive; after: passes.
  • shouldRejectNegativeRetrySettingsTest — negative values still produce the two violations.
  • Regression: mvn -f server/pom.xml test -Dtest='UpdateConsumerGroupSettingsDTOTest,ConsumerGroupControllerTest,MetadataServiceTest' → Tests run: 59, Failures: 0, Errors: 0.

Copilot AI lite review requested due to automatic review settings September 8, 2026 03:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Summary

Fixes a validation inconsistency where UpdateConsumerGroupSettingsDTO rejected retryQueueNums=0 and retryMaxTimes=0 with @positive while the create DTO accepted them with @PositiveOrZero and 0 is a legitimate broker-side value. Simple annotation change aligning update with create. LGTM.


Automated review by RockteMQ-AI

UpdateConsumerGroupSettingsDTO rejects retryQueueNums=0 and
retryMaxTimes=0 with @positive, but both are valid broker-side values
(0 retry queues disables them; 0 retries sends failures straight to the
DLQ) and the sibling CreateConsumerGroupDTO already accepts
retryMaxTimes=0 via @PositiveOrZero. A group created with retryMaxTimes=0
can therefore never re-save its settings while keeping that value - the
endpoint 400s before reaching MetadataService. Align the update DTO with
the create DTO.

Signed-off-by: zjncs <18910855655@163.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants