Skip to content

fix(ai): project empty message trace timelines - #2909

Open
yyqdbngt wants to merge 1 commit into
apache:rocketmq-studiofrom
yyqdbngt:codex/yy-message-trace-projection
Open

fix(ai): project empty message trace timelines#2909
yyqdbngt wants to merge 1 commit into
apache:rocketmq-studiofrom
yyqdbngt:codex/yy-message-trace-projection

Conversation

@yyqdbngt

@yyqdbngt yyqdbngt commented Sep 1, 2026

Copy link
Copy Markdown

Summary

MessageTraceToolHandler projects the trace timeline into the tool output, but assumed MessageService.getMessageTrace always returns a record with populated nodes / consumerStatus lists. Providers may report a missing trace as null (the service's own recordTraceQuery already guards for exactly that case) or as a record whose lists are absent, and the handler turned both shapes into an NPE 500 for AI/MCP/CLI callers.

The projection now treats a missing trace or missing lists as an empty timeline. The tool output schema only requires the arrays to be present, so empty arrays stay schema-valid.

Why

The same trace lookup is also served to the web UI, where a missing trace renders as an empty timeline. MCP/CLI callers of rmq.message.trace should get the same "no trace found" answer instead of an internal error.

Testing

Extended MessageTraceToolHandlerTest with two regression cases: null trace record, and record with null node/consumer-status lists.

mvn -q -Dtest=MessageTraceToolHandlerTest test
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0

@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 NPE in MessageTraceToolHandler when the trace record or its node/consumer-status lists are null. Now projects empty timelines instead of crashing with a 500. Good defensive coding with two test cases covering both null-trace and null-lists scenarios.


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.

3 participants