{"record":{"id":"16d6807bb38b5daf","repo":"aeron-io/aeron","slug":"malformed-command-16d680","errorCode":"MALFORMED_COMMAND","errorMessage":"command={msgTypeId} too short: length={length}","messagePattern":"command=(.+?) too short: length=(.+?)","errorType":"error_code","errorClass":"ControlProtocolException","httpStatus":null,"severity":"error","filePath":"aeron-client/src/main/java/io/aeron/command/RejectImageFlyweight.java","lineNumber":199,"sourceCode":"     * @param reason message to be return to originator.\n     * @return length of the message.\n     */\n    public static int computeLength(final String reason)\n    {\n        return MINIMUM_SIZE + reason.length();\n    }\n\n    /**\n     * Validate buffer length is long enough for message.\n     *\n     * @param msgTypeId type of message.\n     * @param length of message in bytes to validate.\n     */\n    public void validateLength(final int msgTypeId, final int length)\n    {\n        if (length < MINIMUM_SIZE)\n        {\n            throw new ControlProtocolException(\n                MALFORMED_COMMAND, \"command=\" + msgTypeId + \" too short: length=\" + length);\n        }\n\n        if (length < MINIMUM_SIZE + reasonBufferLength())\n        {\n            throw new ControlProtocolException(\n                MALFORMED_COMMAND, \"command=\" + msgTypeId + \" too short: length=\" + length);\n        }\n    }\n}\n","sourceCodeStart":181,"sourceCodeEnd":210,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-client/src/main/java/io/aeron/command/RejectImageFlyweight.java#L181-L210","documentation":"A REJECT_IMAGE control command arrived shorter than MINIMUM_SIZE, the minimum fixed size for the reject-image message. validateLength() throws ControlProtocolException(MALFORMED_COMMAND) because the required fixed fields (session/stream/correlation ids, reason length) would not fit.","triggerScenarios":"A truncated REJECT_IMAGE command on the driver control stream — undersized buffer, wrong msgTypeId routing a smaller message here, or a producer that wrote an incorrect frame length.","commonSituations":"Client/driver version skew; custom tooling rejecting images with hand-built commands; corrupted command queues.","solutions":["Match client and MediaDriver Aeron versions.","Build the command via RejectImageFlyweight API rather than raw byte writes.","Check the frame length written by the producer against MINIMUM_SIZE.","Inspect the driver event log for the offending command to find its source."],"exampleFix":"// before\nsend(rejectBuffer, 0, someSmallLength);\n// after\nint length = RejectImageFlyweight.computeLength(reason.length());\nsend(rejectBuffer, 0, length);","handlingStrategy":"validation","validationCode":"if (length < RejectImageFlyweight.MINIMUM_SIZE) { throw new IllegalArgumentException(\"reject-image command too short: \" + length); }","typeGuard":null,"tryCatchPattern":"try { flyweight.validateLength(msgTypeId, length); } catch (ControlProtocolException e) { if (e.errorCode() == ControlProtocolException.MALFORMED_COMMAND) { logMalformedAndDrop(e); } else { throw e; } }","preventionTips":["Build REJECT_IMAGE commands through the flyweight API","Verify the frame length written matches MINIMUM_SIZE plus reason bytes","Keep Aeron versions aligned","Monitor driver event logs for malformed commands"],"tags":["aeron","control-protocol","malformed-command"],"backgroundTag":"invalid-argument-format","analyzedSha":"6d60124e15e35c11b49ba2e3c2c2858a09a18803","analyzedAt":"2026-09-12T11:17:07.683Z","contentChangedAt":"2026-09-12T11:17:07.683Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}