Skip to content

[ISSUE #11087] Validate lite.bind.topic for LiteTopic groups - #11088

Merged
RongtongJin merged 2 commits into
apache:developfrom
yx9o:dev-0909
Sep 14, 2026
Merged

[ISSUE #11087] Validate lite.bind.topic for LiteTopic groups#11088
RongtongJin merged 2 commits into
apache:developfrom
yx9o:dev-0909

Conversation

@yx9o

@yx9o yx9o commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

@codecov-commenter

codecov-commenter commented Sep 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.35%. Comparing base (fd2dc2f) to head (887adce).
⚠️ Report is 9 commits behind head on develop.

Additional details and impacted files
@@              Coverage Diff              @@
##             develop   #11088      +/-   ##
=============================================
+ Coverage      48.94%   49.35%   +0.41%     
- Complexity     13845    14221     +376     
=============================================
  Files           1382     1390       +8     
  Lines         101597   103130    +1533     
  Branches       13212    13485     +273     
=============================================
+ Hits           49724    50898    +1174     
- Misses         45845    46051     +206     
- Partials        6028     6181     +153     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Summary

This PR strengthens validation for lite.bind.topic in LiteTopic consumer groups by:

  1. Replacing != null checks with StringUtils.isNotBlank() in LiteMetadataUtil — catches empty-string values that previously passed through.
  2. Introducing TopicNameAttribute (extending StringAttribute) to validate topic names at the attribute level via TopicValidator.validateTopic().
  3. Adding comprehensive tests for empty/blank lite.bind.topic in both single and batch delete scenarios, plus attribute-level validation.

The defense-in-depth approach (attribute-level validation + runtime isNotBlank checks) is solid. Tests are thorough and cover edge cases well. LGTM.


Automated review by github-manager

@f1amingo

Copy link
Copy Markdown
Contributor

Reviewed the change — the validation itself is correct. One design suggestion on the attribute abstraction:

All existing Attribute subclasses (StringAttribute, BooleanAttribute, EnumAttribute, LongRangeAttribute) only model a value shape — none embeds a domain concept, and TopicNameAttribute currently serves a single attribute. Since verify is already the extension point, could we make the validation pluggable on StringAttribute instead of introducing a domain-typed subclass?

public class StringAttribute extends Attribute {
    private final Consumer<String> validator;

    public StringAttribute(String name, boolean changeable) {
        this(name, changeable, null);
    }

    public StringAttribute(String name, boolean changeable, Consumer<String> validator) {
        super(name, changeable);
        this.validator = validator;
    }

    @Override
    public void verify(String value) {
        checkNotNull(value);
        if (validator != null) {
            validator.accept(value);
        }
    }
}

and wire it at the declaration site:

public static final StringAttribute LITE_BIND_TOPIC_ATTRIBUTE = new StringAttribute(
    "lite.bind.topic", true, value -> {
        TopicValidator.ValidateResult result = TopicValidator.validateTopic(value);
        if (!result.isValid()) {
            throw new RuntimeException(result.getRemark());
        }
    });

The two-arg constructor remains unchanged, so existing attributes like lite.sub.wildcard keep their behavior, and TopicNameAttribute can be dropped entirely. Not a blocker for correctness — just keeps the framework abstraction shape-only.

@yx9o

yx9o commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

Updated according to your suggestion. Could you please review it again? Thanks @f1amingo

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Summary

This PR adds validation for lite.bind.topic in subscription groups to prevent empty/blank topic names from being used. The changes are well-structured:

  • Replaces null checks with StringUtils.isNotBlank() for robust validation
  • Adds attribute-level validation in StringAttribute with a configurable validator
  • Includes comprehensive test coverage for edge cases (empty strings, blank strings)
  • Properly handles deletion scenarios to avoid cleaning offsets for invalid lite groups

The implementation correctly addresses issue #11087 and follows good defensive programming practices.


Automated review by github-manager-bot

@f1amingo

Copy link
Copy Markdown
Contributor

LGTM

@RongtongJin
RongtongJin merged commit 290d440 into apache:develop Sep 14, 2026
10 of 11 checks passed
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.

[Enhancement] Validate lite.bind.topic with standard topic validation

5 participants