apache/shardingsphere · error · MySQLProtocolException

Can not find value `%s` in new parameters bound flag.

Error message

Can not find value `%s` in new parameters bound flag.

What it means

Thrown by MySQLNewParametersBoundFlag.valueOf(int) when the value is neither 0 (PARAMETER_COUNT_AVAILABLE) nor 1 (PARAMETER_COUNT_NOT_AVAILABLE). This flag appears in COM_STMT_EXECUTE responses parsing; any other byte means the packet stream is corrupted or a new protocol value was introduced.

Source

Thrown at database/protocol/dialect/mysql/src/main/java/org/apache/shardingsphere/database/protocol/mysql/constant/MySQLNewParametersBoundFlag.java:50

    
    PARAMETER_TYPE_NOT_EXIST(0);
    
    private final int value;
    
    /**
     * Value of new parameters bound flag.
     *
     * @param value value
     * @return new parameters bound flag
     * @throws MySQLProtocolException MySQL protocol exception
     */
    public static MySQLNewParametersBoundFlag valueOf(final int value) {
        for (MySQLNewParametersBoundFlag each : values()) {
            if (value == each.value) {
                return each;
            }
        }
        throw new MySQLProtocolException("Can not find value `%s` in new parameters bound flag.", value);
    }
}

View on GitHub (pinned to e952770a21)

Solutions

  1. Verify the client is a real MySQL client speaking a supported protocol version
  2. Check for stream desynchronization: enable packet-level logging and confirm lengths/payload boundaries of preceding packets
  3. Reproduce with a stock mysql client; if it works, the failing client's packet construction is the suspect
  4. Report an upstream bug if a standard client reliably produces flag values other than 0/1
Defensive patterns

Strategy: validation

Validate before calling

// if you build MySQL binary packets, assert the flag before relying on valueOf
int flagByte = buffer.readUnsignedByte();
if (flagByte != 0 && flagByte != 1) {
    throw new IllegalStateException("stream desync: new-params-bound flag=" + flagByte);
}
MySQLNewParametersBoundFlag flag = MySQLNewParametersBoundFlag.valueOf(flagByte);

Try / catch

try {
    MySQLNewParametersBoundFlag.valueOf(value);
} catch (MySQLProtocolException ex) {
    // value outside {0,1}: treat the connection as corrupted and close it;
    // do not resync mid-connection for binary protocol packets
    connection.closeDueToProtocolError(ex);
}

Prevention

When it happens

Trigger: Parsing a binary protocol packet whose new-parameters-bound flag byte is > 1 — typically after earlier bytes of the packet were misparsed, leaving the reader misaligned, or from a malformed/malicious client.

Common situations: Proxy reading a MySQL stream that is out of sync (wrong packet boundary handling after a large payload, compression framing bug), non-MySQL clients connecting to the MySQL port, or protocol changes in very new MySQL versions.

Related errors


AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14). Data as JSON: /api/errors/c3312882ce294f62. Report an issue: GitHub.