aeron-io/aeron · error · ControlProtocolException

MALFORMED_COMMAND

MALFORMED_COMMAND

Error message

command={msgTypeId} too short: length={length}

What it means

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.

Solutions

  1. Align client and driver to the same Aeron version.
  2. Verify the msgTypeId written with the command matches its actual layout.
  3. Inspect the raw command bytes in the driver event log to find where truncation occurred.
  4. If fabricating commands in tests, use the flyweight's LENGTH constant to size the buffer.

Example fix

// before
buffer.ensureCapacity(LENGTH - 4); // undersized
// after
buffer.ensureCapacity(GetNextAvailableSessionIdMessageFlyweight.LENGTH);
Defensive patterns

Strategy: validation

Validate before calling

if (length < GetNextAvailableSessionIdMessageFlyweight.LENGTH) { throw new IllegalArgumentException("command too short: " + length); }

Try / catch

try { flyweight.validateLength(msgTypeId, length); } catch (ControlProtocolException e) { if (e.errorCode() == ControlProtocolException.MALFORMED_COMMAND) { logMalformedAndDrop(e); } else { throw e; } }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of aeron-io/aeron@6d60124e15 (2026-09-12). Data as JSON: /api/errors/6d77085665327131. Report an issue: GitHub.

Appendix: source

Thrown at aeron-client/src/main/java/io/aeron/command/GetNextAvailableSessionIdMessageFlyweight.java:115

     *
     * @return length of the message in bytes.
     */
    public int length()
    {
        return LENGTH;
    }

    /**
     * Validate buffer length is long enough for message.
     *
     * @param msgTypeId type of message.
     * @param length of message in bytes to validate.
     */
    public void validateLength(final int msgTypeId, final int length)
    {
        if (length < LENGTH)
        {
            throw new ControlProtocolException(
                MALFORMED_COMMAND, "command=" + msgTypeId + " too short: length=" + length);
        }
    }
}

View on GitHub (pinned to 6d60124e15)