{"record":{"id":"076c4a5a13270fbe","repo":"apache/rocketmq","slug":"208","errorCode":"208","errorMessage":"query message by id finished, but no message.","messagePattern":"query message by id finished, but no message\\.","errorType":"exception","errorClass":"MQClientException","httpStatus":null,"severity":"error","filePath":"client/src/main/java/org/apache/rocketmq/client/impl/MQAdminImpl.java","lineNumber":273,"sourceCode":"\n        if (brokerAddr != null) {\n            try {\n                return this.mQClientFactory.getMQClientAPIImpl().getEarliestMsgStoretime(brokerAddr, mq, timeoutMillis);\n            } catch (Exception e) {\n                throw new MQClientException(\"Invoke Broker[\" + brokerAddr + \"] exception\", e);\n            }\n        }\n\n        throw new MQClientException(\"The broker[\" + mq.getBrokerName() + \"] not exist\", null);\n    }\n\n    public MessageExt viewMessage(String topic, String msgId)\n        throws RemotingException, MQBrokerException, InterruptedException, MQClientException {\n        MessageId messageId;\n        try {\n            messageId = MessageDecoder.decodeMessageId(msgId);\n        } catch (Exception e) {\n            throw new MQClientException(ResponseCode.NO_MESSAGE, \"query message by id finished, but no message.\");\n        }\n        return this.mQClientFactory.getMQClientAPIImpl().viewMessage(NetworkUtil.socketAddress2String(messageId.getAddress()),\n            topic, messageId.getOffset(), timeoutMillis);\n    }\n\n    public QueryResult queryMessage(String topic, String key, int maxNum, long begin,\n        long end) throws MQClientException,\n        InterruptedException {\n        return queryMessage(null, topic, key, maxNum, begin, end, false, MessageConst.INDEX_KEY_TYPE, null);\n    }\n\n    public QueryResult queryMessageByUniqKey(String topic, String uniqKey, int maxNum, long begin, long end)\n        throws MQClientException, InterruptedException {\n        return queryMessage(null, topic, uniqKey, maxNum, begin, end, true, MessageConst.INDEX_UNIQUE_TYPE, null);\n    }\n\n    public QueryResult queryMessageByUniqKey(String clusterName, String topic, String uniqKey, int maxNum, long begin,\n        long end)","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/apache/rocketmq/blob/293f5885719fc4aa3619446a1900f58ccfcfdd29/client/src/main/java/org/apache/rocketmq/client/impl/MQAdminImpl.java#L255-L291","documentation":"Thrown by MQAdminImpl.viewMessage(topic, msgId) with response code NO_MESSAGE (208) when MessageDecoder.decodeMessageId(msgId) fails to parse the string into a MessageId (broker address + offset). Despite the wording, this is a malformed-msgId parse failure on the client, not a broker query that came back empty — the decode exception is swallowed and this MQClientException is raised instead.","triggerScenarios":"Calling viewMessage(topic, msgId) with a string that is not a valid RocketMQ offset message id: wrong length, non-hex characters, null, or passing a business uniqKey (like a KEY property or generated UUID) where the 32-char offset msgId is required. Client-side only: the broker is never contacted when this fires.","commonSituations":"Passing SendResult.getMsgId() from a NEW API version into an OLD client whose decodeMessageId expects the total-length header (version incompatibility); confusing the unique key with the message id; truncated ids from logs or user input.","solutions":["Ensure msgId is a valid offset message id obtained from SendResult.getMsgId() or MessageExt.getMsgId() from the same client version","To look up by unique key instead, use queryMessageByUniqKey(topic, uniqKey, ...) which queries the index","If ids come from a newer producer, upgrade the client jar so decodeMessageId understands the id format","Validate format before calling: 32 hex chars (or 64 with total-length field) for the installed client version","Check for whitespace/linebreaks accidentally included when ids are copied from logs"],"exampleFix":"// before: uniqKey mistaken for msgId\nMessageExt msg = adminExt.viewMessage(\"T\", \"user-order-12345\"); // decode fails -> 208\n\n// after: query by unique key\nQueryResult r = adminExt.queryMessageByUniqKey(\"T\", \"user-order-12345\", 1, 0, Long.MAX_VALUE);\nMessageExt msg = r.getMessageList().get(0);","handlingStrategy":"validation","validationCode":"private static final Pattern MSG_ID = Pattern.compile(\"^[0-9a-fA-F]{32,64}$\");\nboolean isOffsetMsgId(String s) { return s != null && MSG_ID.matcher(s).matches(); }\n\nif (isOffsetMsgId(msgId)) { adminExt.viewMessage(topic, msgId); }\nelse { adminExt.queryMessageByUniqKey(topic, msgId, 1, 0, Long.MAX_VALUE); }","typeGuard":null,"tryCatchPattern":"try {\n    MessageExt m = adminExt.viewMessage(topic, msgId);\n} catch (MQClientException e) {\n    if (e.getResponseCode() == ResponseCode.NO_MESSAGE) {\n        // msgId unparseable: fall back to uniq-key query\n    } else throw e;\n}","preventionTips":["Store both msgId and uniqKey when producing so lookups have a fallback path","Keep producer and admin client versions aligned so id formats match","Trim ids copied from logs before use"],"tags":["rocketmq","message-id","validation","client"],"backgroundTag":null,"analyzedSha":"293f5885719fc4aa3619446a1900f58ccfcfdd29","analyzedAt":"2026-08-14T11:50:13.822Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}