{"record":{"id":"4374131af625c3ef","repo":"apache/dolphinscheduler","slug":"headerparams-is-not-a-valid-json","errorCode":null,"errorMessage":"headerParams is not a valid json","messagePattern":"headerParams 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":66,"sourceCode":"    private HttpRequestMethod requestType;\n    private int timeout;\n    private String url;\n\n    HttpSender(Map<String, String> paramsMap) {\n        paramsValidator(paramsMap);\n    }\n\n    private void paramsValidator(Map<String, String> paramsMap) {\n        url = paramsMap.get(HttpAlertConstants.NAME_URL);\n        if (StringUtils.isBlank(url)) {\n            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));","sourceCodeStart":48,"sourceCodeEnd":84,"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#L48-L84","documentation":"If the optional 'headerParams' parameter is non-blank, HttpSender parses it with JSONUtils.toMap; a null result (malformed JSON or JSON that is not an object) triggers IllegalArgumentException('headerParams is not a valid json').","triggerScenarios":"headerParams set to non-JSON text, a JSON array, or a scalar, e.g. 'a=1' or '[{\"k\":\"v\"}]'.","commonSituations":"User pastes curl-style '-H \"k: v\"' header syntax instead of a JSON object; quotes stripped by a shell/UI when saving the alert instance.","solutions":["Set headerParams to a valid JSON object, e.g. {\"Authorization\":\"Bearer token\"}.","Validate the JSON (e.g. JSON.parse) before saving the alert params.","Remove headerParams entirely if no custom headers are needed (defaults to empty map)."],"exampleFix":"// before\nheaderParams=Authorization: Bearer xyz\n// after\nheaderParams={\"Authorization\":\"Bearer xyz\"}","handlingStrategy":"validation","validationCode":"String hp = paramsMap.get(\"headerParams\");\nif (hp != null && !hp.isBlank()) { try { new com.fasterxml.jackson.databind.ObjectMapper().readValue(hp, Map.class); } catch (Exception e) { throw new IllegalArgumentException(\"headerParams 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 headerParams json\", e); }","preventionTips":["Use JSON object syntax {\"k\":\"v\"} for headers, not curl -H syntax","Validate JSON in the UI before saving","Omit headerParams if 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"}