{"record":{"id":"602e7d337008ea60","repo":"apache/shardingsphere","slug":"invalid-batch-parameters-buffer","errorCode":null,"errorMessage":"Invalid batch parameters buffer","messagePattern":"Invalid batch parameters buffer","errorType":"exception","errorClass":"FirebirdProtocolException","httpStatus":null,"severity":"error","filePath":"proxy/frontend/dialect/firebird/src/main/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/batch/FirebirdBatchCreateCommandExecutor.java","lineNumber":158,"sourceCode":"                    // blobPolicy = BLOB_STREAM == requestedBlobPolicy ? requestedBlobPolicy : BLOB_STREAM;\n                    // TODO Support BLOB policy after implementing the Firebird batch BLOB subprotocol.\n                    throw new FirebirdProtocolException(\"BLOB policy is not supported in Firebird batch operations\");\n                } else {\n                    reader.skipBytes(valueLength);\n                }\n            }\n            // return new BatchParameters(version, bufferSize, recordCounts, multiError, blobPolicy);\n            return new BatchParameters(version, bufferSize, recordCounts, multiError);\n        }\n        \n        private static long getBufferSize(final int requestedBufferSize) {\n            long result = Integer.toUnsignedLong(requestedBufferSize);\n            return 0L == result ? MAX_BUFFER_SIZE : Math.min(result, MAX_BUFFER_SIZE);\n        }\n        \n        private static void ensureClumpletHeaderReadable(final ByteBuf reader) {\n            if (reader.readableBytes() < 1 + WIDE_CLUMPLET_LENGTH_SIZE) {\n                throw new FirebirdProtocolException(\"Invalid batch parameters buffer\");\n            }\n        }\n        \n        private static void ensureClumpletValueReadable(final ByteBuf reader, final int tag, final int valueLength) {\n            if (valueLength < 0 || valueLength > reader.readableBytes()) {\n                throw new FirebirdProtocolException(\"Invalid batch parameter length for tag %d: %d\", tag, valueLength);\n            }\n        }\n        \n        private static int readIntegerValue(final ByteBuf reader, final int tag, final int valueLength) {\n            if (INTEGER_VALUE_LENGTH != valueLength) {\n                throw new FirebirdProtocolException(\"Invalid batch parameter integer length for tag %d: %d\", tag, valueLength);\n            }\n            return reader.readIntLE();\n        }\n    }\n}\n","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/proxy/frontend/dialect/firebird/src/main/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/batch/FirebirdBatchCreateCommandExecutor.java#L140-L176","documentation":"FirebirdProtocolException ('Invalid batch parameters buffer') from ensureClumpletHeaderReadable: while iterating the batch parameters clumplets, fewer than 5 bytes (1 tag byte + 4 little-endian length bytes) remain but the buffer still claims to be readable. The clumplet stream is truncated or malformed.","triggerScenarios":"BatchParameters.parse() loop: reader.isReadable() is true but reader.readableBytes() < 1 + WIDE_CLUMPLET_LENGTH_SIZE (4). A tag was consumed or a length misread, leaving a partial header; or the client buffer was sliced at a wrong offset.","commonSituations":"hand-built batch parameters buffer with off-by-one length; client writing 2-byte clumplet lengths where the proxy expects 4-byte wide clumplets (batch blocks use wide lengths); buffer truncation from max-packet-size splitting.","solutions":["Use a maintained client library to build the batch parameters block instead of hand-serializing clumplets.","Verify each clumplet is exactly: 1 tag byte, 4-byte little-endian value length, then that many value bytes; ensure the buffer ends exactly at a clumplet boundary.","Check packet reassembly if the batch parameters span multiple network packets."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"catch (SQLException e) {\n    if (e.getMessage().contains(\"Invalid batch parameters buffer\")) { throw new IllegalStateException(\"client clumplet encoding bug (truncated header)\", e); }\n    throw e;\n}","preventionTips":["Format clumplets strictly as tag byte + 4-byte LE length + value.","End the buffer exactly on a clumplet boundary."],"tags":["firebird","batch","clumplet","protocol","malformed-packet"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}