You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "unbridled-41 (via GitHub)" <gi...@apache.org> on 2026/09/05 13:23:11 UTC

[PR] fix(metadata): return empty results for topics without a broker route [rocketmq-dashboard]

unbridled-41 opened a new pull request, #3346:
URL: https://github.com/apache/rocketmq-dashboard/pull/3346

   ### Problem / Evidence
   
   A topic that exists in the Studio metadata database but has no broker route (partially failed create, replaced cluster, DB import) makes two flows fail instead of reporting the documented empty state:
   
   - **Topic detail modal** — `GET /topics/{name}/routes` and `GET /topics/{name}/consumers` both return 502, so `openDetail` (web/src/pages/instance/topic.tsx:511) shows "Topic 详情加载失败,请稍后重试" instead of the modal.
   - **Sync DB topics to broker** — `openSyncModal` (topic.tsx:576) catches the 502 per topic as `routes: null` and filters it out, so `syncMissing` (populated from `routes.length === 0`) never contains the missing-route topics the feature exists to find; the user only sees "部分 Topic 路由校验失败".
   
   Backend trigger: `examineTopicRouteInfo`/`queryTopicConsumeByWho` throw `MQClientException` `CODE: 17` (`TOPIC_NOT_EXIST`, "Not found topic route info in name server for topic: X") which both methods' catch-alls turn into `BusinessException(502)` — the red tests failed with exactly `Failed to get routes for topic TopicA: CODE: 17 DESC: Not found topic route info in name server for topic: TopicA`.
   
   ### Root cause / Fix
   
   `RocketMQMetadataProvider` has no benign-outcome classification for the "topic not on the broker yet" state, unlike its siblings (`RocketMQClientProvider.isTopicNotExist` → `List.of()` for producer connections, merged in #1043; `isGroupNotOnline` → empty for progress/subscriptions in this same class).
   
   Fix: add `isTopicRouteAbsent(MQClientException)` (response code `TOPIC_NOT_EXIST` or the "Not found topic route info" message) and return an empty route list / empty consumer page from the two affected catch blocks. Every other admin failure still surfaces as 502 — the existing `getTopicRoutesSurfacesAdminFailure` and `getTopicConsumersSurfacesAdminFailure` tests pass unchanged, which honors the concern raised in #1163 (real failures must not be disguised as empty data).
   
   ### Priority & scoring
   
   - Impact 30/40 — breaks the topic detail modal and defeats the whole sync-DB-topics feature for route-less records.
   - Scope 12/20 — topic page detail/sync/rebuild flows, two endpoints, one provider.
   - Reproducibility 20/20 — deterministic once a metadata record lacks a broker route.
   - Maintenance value 14/20 — documented contract in the class javadoc ("a record without a broker route surfaces as an empty route list instead of being hidden") plus an in-repo precedent to follow.
   - **PRIORITY = 76, FIX_CONFIDENCE = 90** (≥70/≥80 per the contribution bar).
   
   ### Tests
   
   - New `RocketMQMetadataProviderTest` cases: `getTopicRoutesShouldReturnEmptyListWhenTopicHasNoBrokerRoute` and `getTopicConsumersShouldReturnEmptyPageWhenTopicHasNoBrokerRoute`. Both failed before the fix (BusinessException 502 with `CODE: 17`) and pass after.
   - `mvn -B -ntp test -Dtest='RocketMQMetadataProviderTest,MetadataServiceTest,TopicControllerTest'` → 37/37, 36/36, 16/16 passing.
   - Full `mvn -B -ntp test` on this branch: 2037 tests (pristine baseline 2035 + 2 new); the only 3 failures (`AuthCorsIntegrationTest` ×2, `AliyunInstanceProviderTest.getGroupProgressShouldMapLagRowsTest`) are identical to the recorded pristine baseline. Zero new failures.
   
   ### Risk
   
   Low. The new branch only classifies the definitive TOPIC_NOT_EXIST answer from the name server; transport failures, broker errors and timeouts keep the existing 502 behavior. The related open PR #3102 (name trim/blank guard in `getTopicRoutes`) targets a different defect in the same method; the hunks do not overlap.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(metadata): return empty results for topics without a broker route [rocketmq-dashboard]

Posted by "unbridled-41 (via GitHub)" <gi...@apache.org>.
unbridled-41 commented on PR #3346:
URL: https://github.com/apache/rocketmq-dashboard/pull/3346#issuecomment-5552136461

   ### Verification evidence
   
   - **Red first:** with the fix stashed, `RocketMQMetadataProviderTest` produced the production-shaped errors:
     ```
     getTopicRoutesShouldReturnEmptyListWhenTopicHasNoBrokerRoute → BusinessException
       Failed to get routes for topic TopicA: CODE: 17  DESC: Not found topic route info in name server for topic: TopicA
     getTopicConsumersShouldReturnEmptyPageWhenTopicHasNoBrokerRoute → BusinessException
       Failed to get consumers for topic TopicA: CODE: 17  DESC: Not found topic route info in name server for topic: TopicA
     ```
     (37 run / 2 errors.)
   - **Module tests after the fix:** `mvn -B -ntp test -Dtest='RocketMQMetadataProviderTest,MetadataServiceTest,TopicControllerTest'` → 37/37, 36/36, 16/16 passing. The pre-existing `getTopicRoutesSurfacesAdminFailure` / `getTopicConsumersSurfacesAdminFailure` tests (IllegalStateException → 502) still pass, confirming real admin failures keep surfacing as errors per the #1163 concern.
   - **Full suite:** `mvn -B -ntp test` on this branch → 2037 tests (pristine baseline 2035 + 2 new); the only 3 failures (`AuthCorsIntegrationTest` ×2, `AliyunInstanceProviderTest.getGroupProgressShouldMapLagRowsTest`) are verbatim the pristine-baseline failures. Zero new failures.
   - **CI:** upstream workflows for `rocketmq-studio` PR branches are in `startup_failure` (workflow never starts; same for all recent PRs including other contributors'). Nothing from this branch reaches CI execution.
   - **Scoring:** PRIORITY 76 (impact 30 + scope 12 + reproducibility 20 + maintenance value 14), FIX_CONFIDENCE 90.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(metadata): return empty results for topics without a broker route [rocketmq-dashboard]

Posted by "lizhimins (via GitHub)" <gi...@apache.org>.
lizhimins merged PR #3346:
URL: https://github.com/apache/rocketmq-dashboard/pull/3346


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(metadata): return empty results for topics without a broker route [rocketmq-dashboard]

Posted by "unbridled-41 (via GitHub)" <gi...@apache.org>.
unbridled-41 commented on PR #3346:
URL: https://github.com/apache/rocketmq-dashboard/pull/3346#issuecomment-5570682434

   Thanks @lizhimins — both blocking points are reworked in 86483815:
   
   1. **Genuine 5.5.0 evidence captured.** Reproduced against a live 5.5.0 name server (docker `apache/rocketmq:5.5.0`) querying a route-less topic through this repo's `rocketmq-tools` 5.5.0 client. The client throws `MQClientException` with `responseCode=17` and `errorMessage="No topic route info in name server for the topic: no-such-topic"` — confirming the message-substring branch keyed on a string the client never produces (dead code), and the previously quoted red-test output did not reflect the 5.5.0 client. The PR description now carries the genuine capture and the stale quote is flagged as replaced.
   
   2. **Grading moved to the shared response-code classifier.** The hand-rolled code check and the message-substring fallback are deleted; both catch blocks now grade via `MqResponseCodes.hasResponseCode(e, ResponseCode.TOPIC_NOT_EXIST)` inside the generic `catch (Exception e)`, matching the convention from #3302 (`RocketMQMessageProvider`'s TOPIC_NOT_EXIST/NO_MESSAGE grading). A failure carrying route-absent-looking text with a different response code surfaces as 502 — pinned by new `getTopicRoutesGradesByResponseCodeOnly` / `getTopicConsumersGradesByResponseCodeOnly` tests; the empty-result tests now mock the genuine 5.5.0 exception shape.
   
   Tests: `RocketMQMetadataProviderTest` 40/40; `MetadataServiceTest` 36/36, `TopicControllerTest` 16/16, `MqResponseCodesTest` 6/6; full suite 2094 tests with only the 3 pre-existing baseline failures (re-verified identical on pristine `origin/rocketmq-studio` f5519e87) — zero new failures.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org