aeron-io/aeron · error · ControlProtocolException

MALFORMED_COMMAND

MALFORMED_COMMAND

Error message

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

What it means

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.

Solutions

  1. Match client and MediaDriver Aeron versions.
  2. Build the command via RejectImageFlyweight API rather than raw byte writes.
  3. Check the frame length written by the producer against MINIMUM_SIZE.
  4. Inspect the driver event log for the offending command to find its source.

Example fix

// before
send(rejectBuffer, 0, someSmallLength);
// after
int length = RejectImageFlyweight.computeLength(reason.length());
send(rejectBuffer, 0, length);
Defensive patterns

Strategy: validation

Validate before calling

if (length < RejectImageFlyweight.MINIMUM_SIZE) { throw new IllegalArgumentException("reject-image 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 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.

Common situations: Client/driver version skew; custom tooling rejecting images with hand-built commands; corrupted 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/16d6807bb38b5daf. Report an issue: GitHub.

Appendix: source

Thrown at aeron-client/src/main/java/io/aeron/command/RejectImageFlyweight.java:199

     * @param reason message to be return to originator.
     * @return length of the message.
     */
    public static int computeLength(final String reason)
    {
        return MINIMUM_SIZE + reason.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 < MINIMUM_SIZE)
        {
            throw new ControlProtocolException(
                MALFORMED_COMMAND, "command=" + msgTypeId + " too short: length=" + length);
        }

        if (length < MINIMUM_SIZE + reasonBufferLength())
        {
            throw new ControlProtocolException(
                MALFORMED_COMMAND, "command=" + msgTypeId + " too short: length=" + length);
        }
    }
}

View on GitHub (pinned to 6d60124e15)