Skip to content

Preserve attribute values containing an equals sign in AttributeParser#10552

Open
vasiliy-mikhailov wants to merge 1 commit into
apache:developfrom
vasiliy-mikhailov:fix/attributeparser-split-limit
Open

Preserve attribute values containing an equals sign in AttributeParser#10552
vasiliy-mikhailov wants to merge 1 commit into
apache:developfrom
vasiliy-mikhailov:fix/attributeparser-split-limit

Conversation

@vasiliy-mikhailov

@vasiliy-mikhailov vasiliy-mikhailov commented Jun 27, 2026

Copy link
Copy Markdown

AttributeParser splits each key=value pair on = without a limit, so a value that itself contains = is truncated (only the part before the second = is kept). Split with a limit of 2 so the full value is preserved.

Added a test for a value containing an =.

Verifying this change

The added AttributeParserTest#parseToMap_ValueContainingEqualsSign_PreservesFullValue fails on the current develop and passes with this change:

Before the fix (on develop):

$ mvn test -Dtest=AttributeParserTest -pl common
Running org.apache.rocketmq.common.attribute.AttributeParserTest
Tests run: 12, Failures: 1, Errors: 0, Skipped: 1 <<< FAILURE!
org.junit.ComparisonFailure: expected:<val[=ue]> but was:<val[]>
	at org.apache.rocketmq.common.attribute.AttributeParserTest.parseToMap_ValueContainingEqualsSign_PreservesFullValue(AttributeParserTest.java:128)
[INFO] BUILD FAILURE

After the fix:

$ mvn test -Dtest=AttributeParserTest -pl common
Running org.apache.rocketmq.common.attribute.AttributeParserTest
Tests run: 12, Failures: 0, Errors: 0, Skipped: 0
[INFO] BUILD SUCCESS

AI assistance disclosure

This contribution was produced with the help of an AI pipeline. The pipeline processed a large amount of source code to surface suspected bugs, reproduced a subset of them with failing unit tests and generated candidate fixes, and prepared pull requests from the ones that held up. Each PR was then reviewed and verified by a human before being opened: the fix and test were checked by hand and the test was confirmed to fail before the change and pass after.

The value was split on the equals sign without a limit, truncating values that contain an equals sign. Split with a limit of 2 to keep the full value.

@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.

Review by github-manager-bot

Summary

Changes AttributeParser.parseToMap() to split on = with a limit of 2, so that attribute values containing = characters are preserved instead of being silently truncated.

Findings

  • [Info] AttributeParser.java:47 — The one-line fix (split(ATTR_KEY_VALUE_EQUAL_SIGN, 2)) is the standard Java idiom for key-value parsing where values may contain the delimiter. Correct and minimal.
  • [Info] AttributeParserTest.java:124-128 — Test case "+key=val=ue"{"val=ue"} directly validates the fix.

Verdict

Clean one-line bug fix with a targeted test. LGTM.


Automated review by github-manager-bot

@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.

Review by github-manager-bot

Summary

Fixes AttributeParser.parseToMap() to correctly handle attribute values that contain an equals sign (=) by limiting the split() to 2 parts.

Findings

  • [Info] AttributeParser.java:47 — Changing split(ATTR_KEY_VALUE_EQUAL_SIGN) to split(ATTR_KEY_VALUE_EQUAL_SIGN, 2) is the correct and minimal fix. With limit=2, only the first = is used as a delimiter; everything after it (including additional = characters) is preserved in splits[1].
  • [Info] AttributeParserTest.java:124-128 — Test case parseToMap_ValueContainingEqualsSign_PreservesFullValue directly validates the fix with +key=val=ueval=ue. Good coverage.

Suggestions

  • The existing test testParseBetweenStringAndDistortion already covers round-trip fidelity for simple cases. Consider adding a round-trip test where the value contains = to ensure parseToStringparseToMap round-trips correctly (e.g., +key=val=ue should survive a full round-trip).

Verdict

Clean, minimal one-character fix (split limit). LGTM.


Automated review by github-manager-bot

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.

2 participants