apache / apache/rocketmq-dashboard
[Studio][Bug] Preserve Unicode code points when truncating message properties
- Dominant language
- Java
- Stars
- 1.4k
- Forks
- 683
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 58
Description
## Description
Studio limits displayed message property values to 1024 characters through `MessagePropertyDisplay`. The current implementation uses UTF-16 `String.length()` and `substring(0, 1024)`. If the boundary falls between the high and low surrogate of a supplementary Unicode character such as an emoji, the returned value contains an unpaired surrogate.
The shared utility is used by both regular message details and DLQ message properties, so the malformed truncated value can surface in both APIs and render as a replacement character or invalid Unicode data downstream.
## Steps to reproduce
1. Create a property value containing 1023 ASCII characters, followed by an emoji and more text.
2. Pass it through `MessagePropertyDisplay.limitProperties`.
3. Inspect the final character before the `...` suffix.
## Actual behavior
The output ends with the emoji's isolated high surrogate because the UTF-16 index 1024 splits its surrogate pair.
## Expected behavior
The 1024-character limit should count Unicode code points and truncate only at code-point boundaries. Values containing 1024 code points should remain unchanged; larger values should retain the first 1024 complete code points plus the existing ellipsis suffix.
## Code location
- `server/src/main/java/org/apache/rocketmq/studio/common/util/MessagePropertyDisplay.java`
## Proposed scope
- Make value abbreviation code-point aware.
- Apply the same counting rule in `hasOversizedProperty`.
- Add regression tests for ASCII compatibility, exact emoji boundaries, and oversized mixed text.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with server/src/main/java/org/apache/rocketmq/studio/common/util/MessagePropertyDisplay.java, focusing on limitProperties and hasOversizedProperty. Add regression tests for ASCII values, exact emoji boundaries, and oversized mixed text; done means both methods count Unicode code points, preserve complete characters, and retain the existing ellipsis behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 88/100