{"record":{"id":"1e1ab925b7db71b4","repo":"t8y2/dbx","slug":"message-not-found-s","errorCode":null,"errorMessage":"message not found: %s","messagePattern":"message not found: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/rocketmq/messages.go","lineNumber":192,"sourceCode":"\toffset, hasOffset := optionalInt64(params, \"offset\")\n\tif hasPartition && hasOffset {\n\t\ttargets, targetErr := a.messageQueueTargets(ctx, client, topic, false)\n\t\tif targetErr == nil {\n\t\t\tfor _, target := range targets {\n\t\t\t\tif target.QueueID != partition {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tpullResult, pullErr := client.PullMessage(ctx, target.Address, topic, partition, offset, 1)\n\t\t\t\tif pullErr == nil && len(pullResult.Messages) > 0 {\n\t\t\t\t\treturn map[string]any{\"message\": messageMap(topic, pullResult.Messages[0])}, nil\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif queryErr != nil {\n\t\treturn nil, queryErr\n\t}\n\treturn nil, fmt.Errorf(\"message not found: %s\", messageID)\n}\n\nfunc (a *rocketMQAgent) queryMessageByKey(params map[string]any) (any, error) {\n\ttopic, err := requireString(params, \"topic\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tkey, err := requireString(params, \"key\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tclient, config, _ := a.requireClient()\n\tctx, cancel := context.WithTimeout(context.Background(), config.RequestTimeout)\n\tdefer cancel()\n\tmaxNum := min(max(1, intValue(params, 32, \"maxNum\")), 200)\n\tmessages, err := queryMessagesByKey(ctx, client, config.ConnectTimeout, topic, key, maxNum,\n\t\tint64Value(params, 0, \"begin\"), int64Value(params, time.Now().UnixMilli(), \"end\"))\n\tif err != nil {","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/rocketmq/messages.go#L174-L210","documentation":"viewMessage looks up a message by ID (and falls back to key-based query), and when neither broker lookup finds a match it returns 'message not found: <messageID>'. The driver surfaces this instead of a broker error because admin message-view APIs often return empty results rather than explicit not-found errors.","triggerScenarios":"Calling the viewMessage dispatch operation with a message ID that was already deleted by retention (BrokerPolicy/consumeQueue purge), an ID from a different cluster/topic, a malformed or truncated offsetMsgId, or a typo'd ID.","commonSituations":"Inspecting a message older than the retention window (default 48h/72h); mixing IDs between test and production clusters; copying an ID from a log that truncated it; querying by unique-key that no message carries.","solutions":["Verify the message ID is complete and belongs to the cluster/topic you are querying.","Check the message is still within broker retention (msg retention hours) — expired messages are unrecoverable.","Try viewMessage by message key ('queryMessageByKey') instead of ID if the producer set a key.","Confirm against the broker/topic the message was actually produced to, not a differently-named environment.","If using a client-generated UNIQ_KEY, use the offsetMsgId from send results instead."],"exampleFix":"// before\nmsg, err := agent.ViewMessage(ctx, map[string]any{\"topic\": \"demo\", \"msgId\": logID /* truncated */})\n// after\nmsg, err := agent.ViewMessage(ctx, map[string]any{\"topic\": \"demo\", \"msgId\": sendResult.MsgID /* full offsetMsgId from send */})\nif errors.Is/contains \"message not found\" { /* check retention or query by key */ }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"msg, err := agent.ViewMessage(ctx, map[string]any{\"topic\": topic, \"msgId\": id})\nif err != nil && strings.Contains(err.Error(), \"message not found\") {\n    // treat as 404: check retention window, ID correctness, or fall back to queryMessageByKey\n    return nil, ErrMessageNotFound\n}","preventionTips":["Persist the full offsetMsgId returned at send time; never use truncated log values.","Query messages within the broker retention window (default ~48-72h).","Set a message key at produce time so key-based lookup is available as a fallback.","Confirm the ID was issued by the same cluster/environment you are querying."],"tags":["not-found","rocketmq","message-lookup"],"backgroundTag":"resource-not-found","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}