{"record":{"id":"6d77085665327131","repo":"aeron-io/aeron","slug":"malformed-command-6d7708","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/GetNextAvailableSessionIdMessageFlyweight.java","lineNumber":115,"sourceCode":"     *\n     * @return length of the message in bytes.\n     */\n    public int length()\n    {\n        return 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 < LENGTH)\n        {\n            throw new ControlProtocolException(\n                MALFORMED_COMMAND, \"command=\" + msgTypeId + \" too short: length=\" + length);\n        }\n    }\n}\n","sourceCodeStart":97,"sourceCodeEnd":120,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-client/src/main/java/io/aeron/command/GetNextAvailableSessionIdMessageFlyweight.java#L97-L120","documentation":"A GET_NEXT_AVAILABLE_SESSION_ID control command arrived shorter than its fixed required LENGTH. validateLength() throws ControlProtocolException(MALFORMED_COMMAND) because this message has no variable-length fields — its total size must be exactly (or at least) LENGTH.","triggerScenarios":"A truncated or misaligned command on the driver control stream claiming to be GET_NEXT_AVAILABLE_SESSION_ID but carrying fewer than LENGTH bytes, e.g. wrong msgTypeId routing a smaller message here or a corrupted buffer.","commonSituations":"Client/driver version skew changing message sizes; custom agents or monitoring tools injecting commands into the control stream; buffer offsets corrupted in shared command queues.","solutions":["Align client and driver to the same Aeron version.","Verify the msgTypeId written with the command matches its actual layout.","Inspect the raw command bytes in the driver event log to find where truncation occurred.","If fabricating commands in tests, use the flyweight's LENGTH constant to size the buffer."],"exampleFix":"// before\nbuffer.ensureCapacity(LENGTH - 4); // undersized\n// after\nbuffer.ensureCapacity(GetNextAvailableSessionIdMessageFlyweight.LENGTH);","handlingStrategy":"validation","validationCode":"if (length < GetNextAvailableSessionIdMessageFlyweight.LENGTH) { throw new IllegalArgumentException(\"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":["Size fixed-layout messages using their LENGTH constant","Verify msgTypeId matches the buffer layout actually written","Align client and driver versions","Enable driver event logging to catch corrupted commands early"],"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"}