{"record":{"id":"b6639a3f3d9278a9","repo":"apache/seatunnel","slug":"invalid-json-format-in-request-body","errorCode":null,"errorMessage":"Invalid JSON format in request body.","messagePattern":"Invalid JSON format in request body\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":400,"severity":"error","filePath":"seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/rest/service/BaseService.java","lineNumber":1257,"sourceCode":"                            }\n                        } else {\n                            strValue = value.toString();\n                        }\n                        members.add(key, strValue);\n                    }\n                });\n        return members;\n    }\n\n    protected JsonNode requestHandle(byte[] requestBody) {\n        if (requestBody.length == 0) {\n            throw new IllegalArgumentException(\"Request body is empty.\");\n        }\n        JsonNode requestBodyJsonNode;\n        try {\n            requestBodyJsonNode = RestUtil.convertByteToJsonNode(requestBody);\n        } catch (IOException e) {\n            throw new IllegalArgumentException(\"Invalid JSON format in request body.\");\n        }\n        return requestBodyJsonNode;\n    }\n\n    protected void handleStopJob(\n            Map<String, Object> map, SeaTunnelServer seaTunnelServer, Node node) {\n        boolean isStopWithSavePoint = false;\n        if (map.get(RestConstant.JOB_ID) == null) {\n            throw new IllegalArgumentException(\"jobId cannot be empty.\");\n        }\n        long jobId = Long.parseLong(map.get(RestConstant.JOB_ID).toString());\n        if (map.get(RestConstant.IS_STOP_WITH_SAVE_POINT) != null) {\n            isStopWithSavePoint =\n                    Boolean.parseBoolean(map.get(RestConstant.IS_STOP_WITH_SAVE_POINT).toString());\n        }\n        boolean forceStop = false;\n        if (map.get(RestConstant.FORCE) != null) {\n            forceStop = Boolean.parseBoolean(map.get(RestConstant.FORCE).toString());","sourceCodeStart":1239,"sourceCodeEnd":1275,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/rest/service/BaseService.java#L1239-L1275","documentation":"requestHandle converts the raw request bytes to JSON via RestUtil.convertByteToJsonNode. If the bytes are present but not valid JSON (IOException), it throws IllegalArgumentException(\"Invalid JSON format in request body.\").","triggerScenarios":"POSTing malformed JSON (missing braces/quotes, trailing commas) or a non-JSON payload (plain text, form-encoded) to body-based REST endpoints.","commonSituations":"Hand-written curl payloads with quoting mistakes on the shell; wrong Content-Type causing garbled encoding; clients sending YAML/XML instead of JSON.","solutions":["Validate the JSON payload with a JSON parser before sending","Quote the body correctly in shell (use single quotes or heredoc) to avoid shell mangling","Send proper Content-Type: application/json and a JSON-serializable body"],"exampleFix":"// before\ncurl -d '{\"jobId\": 123,' ...   // malformed JSON\n// after\ncurl -H 'Content-Type: application/json' -d '{\"jobId\":\"123\"}' ...","handlingStrategy":"validation","validationCode":"JSON.parse(payload); // throws early if invalid before HTTP call","typeGuard":null,"tryCatchPattern":"try {\n    const res = await post(url, JSON.stringify(payload));\n} catch (e) {\n    if (String(e).includes('Invalid JSON format')) {\n        // fix serialization/quoting and resend\n    }\n}","preventionTips":["Validate JSON before sending (linters/parsers)","Quote bodies correctly in shell commands","Never send form-encoded or YAML bodies to JSON endpoints"],"tags":["rest-api","json","validation"],"backgroundTag":"json-parse-error","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}