{"record":{"id":"95f18f5760f17cb4","repo":"apache/seatunnel","slug":"invalid-batch-batchid-in-request","errorCode":null,"errorMessage":"Invalid BATCH batchId in request: {}","messagePattern":"Invalid BATCH batchId in request: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"seatunnel-connectors-v2/connector-edge-socket/src/main/java/org/apache/seatunnel/connectors/seatunnel/edgesocket/protocol/IngressProtocolHandler.java","lineNumber":138,"sourceCode":"                    EdgeSocketLogUtils.abbreviateForLog(request));\n            return EdgeSocketResponseCode.INVALID_PARAM.getCode();\n        }\n        return handler.handleCommitRequest(batchId);\n    }\n\n    private String dispatchBatch(String request) {\n        int separatorIndex = request.indexOf(':', IngressCommand.BATCH.prefix().length());\n        if (separatorIndex < 0) {\n            log.warn(\n                    \"Malformed BATCH request, missing payload separator: {}\",\n                    EdgeSocketLogUtils.abbreviateForLog(request));\n            return EdgeSocketResponseCode.BAD_REQUEST.getCode();\n        }\n        Long batchId =\n                parseBatchId(request.substring(0, separatorIndex), IngressCommand.BATCH.prefix());\n        if (batchId == null || batchId <= 0) {\n            log.warn(\n                    \"Invalid BATCH batchId in request: {}\",\n                    EdgeSocketLogUtils.abbreviateForLog(request));\n            return EdgeSocketResponseCode.INVALID_PARAM.getCode();\n        }\n        String payload = request.substring(separatorIndex + 1);\n        return handler.handleBatchRecord(batchId, payload);\n    }\n\n    private static boolean constantTimeEquals(String expected, String actual) {\n        if (expected == null || actual == null) {\n            return Objects.equals(expected, actual);\n        }\n        byte[] a = expected.getBytes(StandardCharsets.UTF_8);\n        byte[] b = actual.getBytes(StandardCharsets.UTF_8);\n        return MessageDigest.isEqual(a, b);\n    }\n\n    private static String parseAuthToken(String authLine) {\n        if (IngressCommand.AUTH.matches(authLine)) {","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-edge-socket/src/main/java/org/apache/seatunnel/connectors/seatunnel/edgesocket/protocol/IngressProtocolHandler.java#L120-L156","documentation":"Logged by dispatchBatch() when the segment before the ':' separator in a BATCH request does not parse to a positive long batch id. The server replies INVALID_PARAM and drops the request without calling the handler. This protects the batch record path from unusable identifiers.","triggerScenarios":"A request like 'BATCH abc:payload', 'BATCH :payload', or 'BATCH -5:payload' where parseBatchId on the substring before ':' returns null or a value <= 0.","commonSituations":"Collector bug substituting a non-numeric placeholder for the id, off-by-one substring logic on the client, ids overflowing or being reset to 0/negative after wraparound.","solutions":["Fix the collector to emit a positive numeric id: 'BATCH <positive-long>:<payload>'.","Review the collector's batch id generation/counter for null, zero, or negative values.","Use the abbreviated request in the log to confirm the exact malformed line."],"exampleFix":"// before (client)\nwriter.write(\"BATCH \" + String.valueOf(counter++) + \":\" + payload); // counter started at 0\n// after\nlong batchId = ++counter; writer.write(\"BATCH \" + batchId + \":\" + payload);","handlingStrategy":"validation","validationCode":"if (!(Long.parseLong(idPart) > 0)) { throw new IllegalArgumentException(\"BATCH idPart must be a positive long: \" + idPart); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use an atomic long counter starting at 1 for batch ids","Validate the id before formatting the request","Log ids once at creation to catch zero/negative drift early"],"tags":["protocol","validation","batch-id"],"backgroundTag":"invalid-argument-value","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}