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
- Verify the client is a real MySQL client speaking a supported protocol version
- Check for stream desynchronization: enable packet-level logging and confirm lengths/payload boundaries of preceding packets
- Reproduce with a stock mysql client; if it works, the failing client's packet construction is the suspect
- 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
- Only send 0/1 for the new-parameters-bound flag in generated COM_STMT_EXECUTE payloads
- Validate packet framing (sequence ids, lengths) before parsing fields to avoid downstream misreads
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
- Wrong length `%d` of MYSQL_TYPE_TIME
- Wrong length `%d` of MYSQL_TYPE_DATE
- Can not support type `%s`.
- HiveServer2 in embedded mode has been deprecated by Apache H
- 6
AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14).
Data as JSON: /api/errors/c3312882ce294f62.
Report an issue: GitHub.