apache/shardingsphere · error · PostgreSQLProtocolException
Can not find `%s` in PostgreSQL identifier tag type.
Error message
Can not find `%s` in PostgreSQL identifier tag type.
What it means
PostgreSQLMessagePacketType.valueOf(int) maps the leading byte of a backend/frontend message to a known packet type enum. An unrecognized value throws PostgreSQLProtocolException 'Can not find `%s` in PostgreSQL identifier tag type.', meaning the first byte of the message does not correspond to any known PostgreSQL command tag.
Source
Thrown at database/protocol/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/protocol/postgresql/packet/identifier/PostgreSQLMessagePacketType.java:108
PORTAL_SUSPENDED('s');
private final char value;
/**
* Value of integer.
*
* @param value integer value
* @return command packet type enum
* @throws PostgreSQLProtocolException PostgreSQL protocol exception
*/
public static PostgreSQLMessagePacketType valueOf(final int value) {
for (PostgreSQLMessagePacketType each : values()) {
if (value == each.value) {
return each;
}
}
throw new PostgreSQLProtocolException("Can not find `%s` in PostgreSQL identifier tag type.", value);
}
}
View on GitHub (pinned to e952770a21)
Solutions
- Verify the client is a real PostgreSQL-protocol client and connects with the correct startup sequence (including SSL negotiation)
- Check earlier messages' length prefixes for correctness — a bad length desynchronizes the stream and surfaces here
- Compare the failing byte value against the protocol spec to see which message the peer thought it was sending
- Enable packet-level logging and test the same client against a vanilla PostgreSQL to isolate proxy-side desync
Defensive patterns
Strategy: validation
Validate before calling
int tag = buffer.readByte() & 0xff;
if (!PostgreSQLMessagePacketType.knownTags().contains(tag)) { /* drop connection, log tag */ } Try / catch
catch (PostgreSQLProtocolException e) { /* treat as protocol desync: close connection, do not retry on same stream */ } Prevention
- Handle SSLRequest/startup negotiation in the exact protocol order
- Validate message length prefixes before consuming payloads
- Reject non-PostgreSQL clients at startup handshake
When it happens
Trigger: The packet decoder reads a message tag byte that is not one of the enumerated tags — stream misalignment (reading a tag from the middle of a previous message), a truncated stream, or an unencrypted/SSL byte where a tag was expected (e.g. SSL negotiation handled incorrectly).
Common situations: Startup sequence handled out of order, SSLRequest vs regular startup confusion, earlier message length fields lying about payload size causing desync, or non-PostgreSQL clients connecting to the port.
Related errors
- Connection [%s] is not registered.
- BLR is too short: %s
- Unsupported PostgreSQL format code `%s`
- Can not find `%s` in PostgreSQL command packet type.
- Can not find value `%s` in PostgreSQL column type.
AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14).
Data as JSON: /api/errors/41391259ff3f8ab0.
Report an issue: GitHub.