{"record":{"id":"2fb396ce980e68f3","repo":"apache/shardingsphere","slug":"blr-is-too-short-s","errorCode":null,"errorMessage":"BLR is too short: %s","messagePattern":"BLR is too short: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"warning","filePath":"database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/batch/FirebirdParseBatchBlr.java","lineNumber":75,"sourceCode":"        validateSupported(result.fields);\n        return result;\n    }\n    \n    /**\n     * Parse a BLR message buffer into its message format for codec framing only, without semantic support validation.\n     *\n     * <p>Used by the packet codec to split a coalesced {@code BATCH_CREATE + BATCH_MSG} frame. Semantically unsupported\n     * but structurally valid fields (such as BLOB) are returned as descriptors instead of being rejected here, so that the\n     * rejection happens later on the command/error path rather than as a codec-level channel close.</p>\n     *\n     * @param blr BLR buffer\n     * @param blrLength BLR length\n     * @return parsed message format\n     * @throws IllegalArgumentException when BLR format is structurally invalid\n     */\n    public static FirebirdParseBatchBlr parseForFraming(final ByteBuf blr, final int blrLength) {\n        if (blrLength < HEADER_LENGTH) {\n            throw new IllegalArgumentException(\"BLR is too short: \" + blrLength);\n        }\n        ByteBuf buffer = blr.duplicate();\n        final int startReaderIndex = buffer.readerIndex();\n        int version = buffer.readUnsignedByte();\n        if (BlrConstants.blr_version4 != version && BlrConstants.blr_version5 != version) {\n            throw new IllegalArgumentException(\"Unsupported BLR version: \" + version);\n        }\n        if (BlrConstants.blr_begin != buffer.readUnsignedByte()) {\n            throw new IllegalArgumentException(\"Expected blr_begin\");\n        }\n        if (BlrConstants.blr_message != buffer.readUnsignedByte()) {\n            throw new IllegalArgumentException(\"Expected blr_message\");\n        }\n        buffer.skipBytes(1);\n        FirebirdParseBatchBlr result = parseFormat(buffer);\n        validateTermination(buffer, startReaderIndex, blrLength);\n        return result;\n    }","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/database/protocol/dialect/firebird/src/main/java/org/apache/shardingsphere/database/protocol/firebird/packet/command/query/batch/FirebirdParseBatchBlr.java#L57-L93","documentation":"UnsupportedSQLOperationException thrown by PostgreSQLComDescribeExecutor when a Describe message's type byte is neither 'S' (prepared statement) nor 'P' (portal). Per the extended protocol, Describe must name one of those two objects; any other type byte reaches the default branch and the message embeds the offending type.","triggerScenarios":"Sending a Describe message with an invalid type byte — custom wire-protocol clients, corrupted packets, or driver bugs — e.g. describing with type 'Q' or 0x00.","commonSituations":"Hand-rolled extended-protocol implementations that confuse the Describe type with Close/Execute fields; fuzzing tools; stream corruption through proxies/LBs; driver regressions that marshal the type byte incorrectly.","solutions":["Send Describe with type 'S' to describe a prepared statement or 'P' to describe a portal, following the PostgreSQL protocol.","Add client-side validation of the message type byte before writing Describe to the socket.","Upgrade/patch the driver if it is responsible for emitting the bad type; check its changelog for extended-protocol fixes.","Capture the wire bytes to rule out in-transit corruption when the client claims to send a valid type."],"exampleFix":"// before (custom client)\ndescribe(type='T', name=\"stmt1\");\n\n// after\ndescribe(type='S', name=\"stmt1\"); // statement; use 'P' for a portal","handlingStrategy":"validation","validationCode":"// Custom client: validate Describe message before sending\nbyte type = describeTarget;\nif (type != 'S' && type != 'P') {\n    throw new IllegalArgumentException(\"Invalid Describe type byte: \" + (char) type);\n}\nsendDescribe(type, name);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only 'S' or 'P' as the Describe type byte.","Keep a shared enum for extended-protocol message target types to avoid typos.","When this fires unexpectedly, capture wire bytes to check for in-transit corruption."],"tags":["postgresql","extended-protocol","describe","protocol"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}