{"record":{"id":"ad9e251094a5094d","repo":"apache/pulsar","slug":"invalid-message-id-must-be-in-format-ledgerid-en","errorCode":null,"errorMessage":"Invalid message id (must be in format: ledgerId:entryId) value ${resetMessageIdStr}","messagePattern":"Invalid message id \\(must be in format: ledgerId:entryId\\) value (.+?)","errorType":"validation","errorClass":"PulsarAdminException","httpStatus":null,"severity":"error","filePath":"pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CliCommand.java","lineNumber":79,"sourceCode":"    static String validateNonPersistentTopic(String topic) {\n        TopicName topicName = TopicName.get(topic);\n        if (topicName.getDomain() != TopicDomain.non_persistent) {\n            throw new IllegalArgumentException(\"Need to provide a non-persistent topic name\");\n        }\n        return topicName.toString();\n    }\n\n    static MessageId validateMessageIdString(String resetMessageIdStr) throws PulsarAdminException {\n        return validateMessageIdString(resetMessageIdStr, -1);\n    }\n\n    static MessageId validateMessageIdString(String resetMessageIdStr, int partitionIndex) throws PulsarAdminException {\n        String[] messageId = resetMessageIdStr.split(\":\");\n        try {\n            com.google.common.base.Preconditions.checkArgument(messageId.length == 2);\n            return new MessageIdImpl(Long.parseLong(messageId[0]), Long.parseLong(messageId[1]), partitionIndex);\n        } catch (Exception e) {\n            throw new PulsarAdminException(\n                    \"Invalid message id (must be in format: ledgerId:entryId) value \" + resetMessageIdStr);\n        }\n    }\n\n    Set<AuthAction> getAuthActions(List<String> actions) {\n        Set<AuthAction> res = new TreeSet<>();\n        AuthAction authAction;\n        for (String action : actions) {\n            try {\n                authAction = AuthAction.valueOf(action);\n            } catch (IllegalArgumentException exception) {\n                throw new ParameterException(String.format(\"Illegal auth action '%s'. Possible values: %s\",\n                        action, Arrays.toString(AuthAction.values())));\n            }\n            res.add(authAction);\n        }\n\n        return res;","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CliCommand.java#L61-L97","documentation":"CliCommand.validateMessageIdString parses a message id string that must be exactly 'ledgerId:entryId' (two colon-separated longs), optionally attaching a partition index. Guava Preconditions.checkArgument and Long.parseLong failures are caught and rethrown as PulsarAdminException with the offending value echoed, so any malformed input lands here.","triggerScenarios":"Passing a reset-cursor or similar admin command a message id that is not ledgerId:entryId — e.g. '123:45:67', 'abc:def', '123-45', an empty string, or a MessageId.toString() variant with extra components like 'ledgerId:entryId:partitionIndex'.","commonSituations":"Copy-pasting a message id from logs that includes extra fields; using a broker's verbose message id format with batch index or partition suffix; typos in manual cursor-reset operations; using 'latest'/'earliest' special values where the command expects numeric ids.","solutions":["Format the argument as exactly two colon-separated longs: ledgerId:entryId (e.g. 12:34)","Strip extra components (partition index, batch index) from the copied message id before passing it","Verify both parts are valid non-empty decimal longs with no whitespace","If you have a MessageId object, serialize it yourself into 'ledgerId:entryId' rather than trusting toString() output"],"exampleFix":"// before\n--message-id 12:34:5\n// after\n--message-id 12:34","handlingStrategy":"validation","validationCode":"// Validate the message id string before passing it to the CLI\nString mid = resetMessageIdStr.trim();\nif (!mid.matches(\"\\\\d+:\\\\d+\")) {\n    throw new IllegalArgumentException(\"message id must be ledgerId:entryId, got: \" + resetMessageIdStr);\n}","typeGuard":null,"tryCatchPattern":"try {\n    admin.topics().resetCursor(topic, subscription, messageId);\n} catch (PulsarAdminException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"Invalid message id\")) {\n        log.error(\"Fix format to ledgerId:entryId; input was: {}\", resetMessageIdStr);\n    }\n    throw e;\n}","preventionTips":["Always supply exactly two colon-separated longs: ledgerId:entryId","Strip partition/batch suffixes from message ids copied from logs before reuse","Store message ids for cursor resets in the normalized ledgerId:entryId form","Regex-validate the input in wrapper scripts around pulsar-admin"],"tags":["cli","pulsar-admin","message-id","argument-validation","parsing"],"backgroundTag":"invalid-message-id-format","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}