{"record":{"id":"845dbf886889a927","repo":"apache/dolphinscheduler","slug":"bodyparams-is-not-a-valid-json","errorCode":null,"errorMessage":"bodyParams is not a valid json","messagePattern":"bodyParams is not a valid json","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpSender.java","lineNumber":77,"sourceCode":"            throw new IllegalArgumentException(\"url can not be null\");\n        }\n\n        String headerParamsString = paramsMap.get(HttpAlertConstants.NAME_HEADER_PARAMS);\n        if (StringUtils.isNotBlank(headerParamsString)) {\n            headerParams = JSONUtils.toMap(headerParamsString);\n            if (headerParams == null) {\n                throw new IllegalArgumentException(\"headerParams is not a valid json\");\n            }\n        } else {\n            headerParams = new HashMap<>();\n        }\n\n        String bodyParamsString = paramsMap.get(HttpAlertConstants.NAME_BODY_PARAMS);\n        if (StringUtils.isNotBlank(bodyParamsString)) {\n            bodyParams = JSONUtils.parseObject(bodyParamsString, new TypeReference<Map<String, Object>>() {\n            });\n            if (bodyParams == null) {\n                throw new IllegalArgumentException(\"bodyParams is not a valid json\");\n            }\n        } else {\n            bodyParams = new HashMap<>();\n        }\n\n        try {\n            requestType = HttpRequestMethod.valueOf(paramsMap.get(HttpAlertConstants.NAME_REQUEST_TYPE));\n        } catch (IllegalArgumentException e) {\n            throw new IllegalArgumentException(\"requestType is not a valid value\");\n        }\n\n        contentType = OkHttpRequestHeaderContentType.fromValue(paramsMap.get(HttpAlertConstants.NAME_CONTENT_TYPE));\n        if (contentType == null) {\n            throw new IllegalArgumentException(\"contentType is not a valid value\");\n        }\n\n        timeout = (StringUtils.isNotBlank(paramsMap.get(HttpAlertConstants.NAME_TIMEOUT))\n                ? Integer.parseInt(paramsMap.get(HttpAlertConstants.NAME_TIMEOUT))","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpSender.java#L59-L95","documentation":"The optional 'bodyParams' parameter, when non-blank, is parsed with JSONUtils.parseObject into Map<String,Object>; a null result means the string is not valid JSON, raising IllegalArgumentException('bodyParams is not a valid json').","triggerScenarios":"bodyParams contains non-JSON text, a JSON array/scalar where an object is required, or trailing commas/invalid escapes.","commonSituations":"Sending form-style 'key=value&k2=v2' body instead of a JSON object; shell quoting mangling double quotes when saving params.","solutions":["Provide bodyParams as a valid JSON object, e.g. {\"key\":\"value\"}.","Validate the JSON before saving; remove bodyParams if a raw body is used elsewhere.","Use double quotes for keys/strings inside the JSON object."],"exampleFix":"// before\nbodyParams=key1=value1&key2=value2\n// after\nbodyParams={\"key1\":\"value1\",\"key2\":\"value2\"}","handlingStrategy":"validation","validationCode":"String bp = paramsMap.get(\"bodyParams\");\nif (bp != null && !bp.isBlank()) { try { new com.fasterxml.jackson.databind.ObjectMapper().readValue(bp, Map.class); } catch (Exception e) { throw new IllegalArgumentException(\"bodyParams must be a JSON object\"); } }","typeGuard":"boolean isJsonObject(String s) { if (s == null) return true; try { return JSONUtils.parseObject(s, new TypeReference<Map<String,Object>>(){}) != null; } catch (Exception e) { return false; } }","tryCatchPattern":"try { new HttpAlert(paramsMap); } catch (IllegalArgumentException e) { log.error(\"invalid bodyParams json\", e); }","preventionTips":["Use a JSON object for bodyParams, not form-urlencoded strings","Lint the JSON before saving the alert config","Omit bodyParams when unused"],"tags":["json","http","configuration"],"backgroundTag":"json-parse-error","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}