{"record":{"id":"0a17fa71e72eb116","repo":"t8y2/dbx","slug":"topic-stats-not-found-s","errorCode":null,"errorMessage":"topic stats not found: %s","messagePattern":"topic stats not found: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/rocketmq/topics.go","lineNumber":304,"sourceCode":"\t\tif requestErr != nil {\n\t\t\tlastErr = requestErr\n\t\t\tcontinue\n\t\t}\n\t\tpartial, decodeErr := decodeTopicStats(response.Body)\n\t\tif decodeErr != nil {\n\t\t\tlastErr = decodeErr\n\t\t\tcontinue\n\t\t}\n\t\tsuccessCount++\n\t\tfor key, offset := range partial {\n\t\t\tmerged[key] = offset\n\t\t}\n\t}\n\tif successCount != len(addresses) {\n\t\treturn nil, fmt.Errorf(\"query topic stats for %s on all masters: %w\", topic, lastErr)\n\t}\n\tif len(merged) == 0 {\n\t\treturn nil, fmt.Errorf(\"topic stats not found: %s\", topic)\n\t}\n\treturn merged, nil\n}\n\nfunc decodeTopicStats(body []byte) (map[string]*admin.TopicOffset, error) {\n\tvar stats admin.TopicStatsTable\n\tif err := json.Unmarshal(repairRocketMQJSON(body), &stats); err != nil {\n\t\treturn nil, fmt.Errorf(\"decode topic stats: %w\", err)\n\t}\n\tif stats.OffsetTable == nil {\n\t\tstats.OffsetTable = make(map[string]*admin.TopicOffset)\n\t}\n\treturn stats.OffsetTable, nil\n}\n\nfunc masterAddressesFromRoute(route *admin.TopicRouteData) []string {\n\taddresses := make(map[string]struct{})\n\tfor _, broker := range route.BrokerDatas {","sourceCodeStart":286,"sourceCodeEnd":322,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/rocketmq/topics.go#L286-L322","documentation":"This error means examineTopicStats successfully queried every master broker for the topic's stats (GetTopicStatsInfo), but the merged offset table came back empty. The library throws it because a topic that exists on the route should have at least one queue with offsets; an empty result means the topic effectively has no stats recorded on any broker (e.g. no queues ever created/used).","triggerScenarios":"examineTopicStats (via listProducers or getTopicStats) is called for a topic whose route resolves to master brokers, all brokers answer successfully, but every broker returns an empty offsetTable — typically a freshly created topic with readQueueNums/writeQueueNums of 0, or a topic whose queues were deleted.","commonSituations":"Querying stats for a topic that was created but never had queues provisioned; a topic auto-deleted after idle; callers listing stats across topics where some are empty stubs; name typos that still match a stale empty topic registration on the nameserver.","solutions":["Verify the topic actually has queues: check readQueueNums/writeQueueNums > 0 via getTopicConfig; if 0, use updatePartitions to provision queues first","Confirm the topic name matches exactly (RocketMQ topics are case-sensitive and percent/char-sensitive)","Check broker-side that the topic's offset table exists (consumer/producer has published or subscribed at least once)","If the topic is intentionally empty, treat this error as 'no data' in the caller rather than retrying"],"exampleFix":"// before\nstats, err := agent.getTopicStats(topic)\nif err != nil { return err }\n// after\nstats, err := agent.getTopicStats(topic)\nif err != nil {\n    if strings.Contains(err.Error(), \"topic stats not found\") {\n        return emptyStats(topic), nil // treat empty topic as zero-stats\n    }\n    return err\n}","handlingStrategy":"validation","validationCode":"cfg, err := agent.getTopicConfig(topic)\nif err != nil { return err }\nif cfg.readQueueNums == 0 && cfg.writeQueueNums == 0 {\n    return fmt.Errorf(\"topic %s has no queues; stats will be empty\", topic)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Provision queues (updatePartitions) immediately after creating a topic","Check queue nums > 0 before querying stats","Treat 'topic stats not found' as an empty-result signal, not a retryable failure"],"tags":["rocketmq","topic-stats","empty-result"],"backgroundTag":"topic-not-found","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}