{"record":{"id":"a1fdd7d18bc54a69","repo":"aeron-io/aeron","slug":"malformed-command-a1fdd7","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/PublicationMessageFlyweight.java","lineNumber":155,"sourceCode":"     *\n     * @return the length of the current message.\n     */\n    public int length()\n    {\n        return CHANNEL_OFFSET + lengthOfChannel;\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_LENGTH)\n        {\n            throw new ControlProtocolException(\n                MALFORMED_COMMAND, \"command=\" + msgTypeId + \" too short: length=\" + length);\n        }\n\n        if ((length - MINIMUM_LENGTH) < buffer.getInt(offset + CHANNEL_OFFSET))\n        {\n            throw new ControlProtocolException(\n                MALFORMED_COMMAND, \"command=\" + msgTypeId + \" too short for channel: length=\" + length);\n        }\n    }\n\n    /**\n     * Compute the length of the command message for a given channel length.\n     *\n     * @param channelLength to be appended to the header.\n     * @return the length of the command message for a given channel length.\n     */\n    public static int computeLength(final int channelLength)\n    {","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-client/src/main/java/io/aeron/command/PublicationMessageFlyweight.java#L137-L173","documentation":"A publication-related control command arrived with a total length below the fixed MINIMUM_LENGTH required by PublicationMessageFlyweight. validateLength() throws ControlProtocolException(MALFORMED_COMMAND), aborting the command because even the fixed header fields would not fit.","triggerScenarios":"An ADD_PUBLICATION / REMOVE_PUBLICATION style command shorter than MINIMUM_LENGTH — truncated write into the driver control buffer, wrong msgTypeId mapping, or a producer that mis-sized the frame.","commonSituations":"Version mismatch between client and MediaDriver message layouts; custom or buggy command multiplexers; corrupted command queues in shared-memory transports.","solutions":["Run matching Aeron client and driver versions.","Use the flyweight's computeLength() API instead of manual byte counts when emitting commands.","Inspect driver event logs to capture the malformed command and locate its producer.","Ensure the full command frame is written atomically to the control stream with no truncation."],"exampleFix":"// before\nint length = 8; // guessed header size\n// after\nint length = PublicationMessageFlyweight.computeLength(encodedChannel.length());","handlingStrategy":"validation","validationCode":"if (length < PublicationMessageFlyweight.MINIMUM_LENGTH) { throw new IllegalArgumentException(\"publication command too short: \" + length); }","typeGuard":null,"tryCatchPattern":"try { flyweight.validateLength(msgTypeId, length); } catch (ControlProtocolException e) { if (e.errorCode() == ControlProtocolException.MALFORMED_COMMAND) { log.error(\"Dropping malformed publication command\", e); } else { throw e; } }","preventionTips":["Size publication commands via computeLength()","Keep client and MediaDriver versions identical","Write control frames atomically","Check driver event log when commands come from custom code"],"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"}