t8y2/dbx · error
message not found: %s
Error message
message not found: %s
What it means
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.
Source
Thrown at agents/drivers/rocketmq/messages.go:192
offset, hasOffset := optionalInt64(params, "offset")
if hasPartition && hasOffset {
targets, targetErr := a.messageQueueTargets(ctx, client, topic, false)
if targetErr == nil {
for _, target := range targets {
if target.QueueID != partition {
continue
}
pullResult, pullErr := client.PullMessage(ctx, target.Address, topic, partition, offset, 1)
if pullErr == nil && len(pullResult.Messages) > 0 {
return map[string]any{"message": messageMap(topic, pullResult.Messages[0])}, nil
}
}
}
}
if queryErr != nil {
return nil, queryErr
}
return nil, fmt.Errorf("message not found: %s", messageID)
}
func (a *rocketMQAgent) queryMessageByKey(params map[string]any) (any, error) {
topic, err := requireString(params, "topic")
if err != nil {
return nil, err
}
key, err := requireString(params, "key")
if err != nil {
return nil, err
}
client, config, _ := a.requireClient()
ctx, cancel := context.WithTimeout(context.Background(), config.RequestTimeout)
defer cancel()
maxNum := min(max(1, intValue(params, 32, "maxNum")), 200)
messages, err := queryMessagesByKey(ctx, client, config.ConnectTimeout, topic, key, maxNum,
int64Value(params, 0, "begin"), int64Value(params, time.Now().UnixMilli(), "end"))
if err != nil {View on GitHub (pinned to c0390bff16)
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.
Example fix
// before
msg, err := agent.ViewMessage(ctx, map[string]any{"topic": "demo", "msgId": logID /* truncated */})
// after
msg, err := agent.ViewMessage(ctx, map[string]any{"topic": "demo", "msgId": sendResult.MsgID /* full offsetMsgId from send */})
if errors.Is/contains "message not found" { /* check retention or query by key */ } Defensive patterns
Strategy: try-catch
Try / catch
msg, err := agent.ViewMessage(ctx, map[string]any{"topic": topic, "msgId": id})
if err != nil && strings.Contains(err.Error(), "message not found") {
// treat as 404: check retention window, ID correctness, or fall back to queryMessageByKey
return nil, ErrMessageNotFound
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- no RocketMQ master broker found for topic %s
- View source not found: " + name
- MongoDB collection '<sourceName>' was not found
- Object source not found
- ETCD_NOT_FOUND
AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05).
Data as JSON: /api/errors/1e1ab925b7db71b4.
Report an issue: GitHub.