apache/dolphinscheduler · error · IllegalArgumentException
bodyParams is not a valid json
Error message
bodyParams is not a valid json
What it means
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').
Source
Thrown at dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpSender.java:77
throw new IllegalArgumentException("url can not be null");
}
String headerParamsString = paramsMap.get(HttpAlertConstants.NAME_HEADER_PARAMS);
if (StringUtils.isNotBlank(headerParamsString)) {
headerParams = JSONUtils.toMap(headerParamsString);
if (headerParams == null) {
throw new IllegalArgumentException("headerParams is not a valid json");
}
} else {
headerParams = new HashMap<>();
}
String bodyParamsString = paramsMap.get(HttpAlertConstants.NAME_BODY_PARAMS);
if (StringUtils.isNotBlank(bodyParamsString)) {
bodyParams = JSONUtils.parseObject(bodyParamsString, new TypeReference<Map<String, Object>>() {
});
if (bodyParams == null) {
throw new IllegalArgumentException("bodyParams is not a valid json");
}
} else {
bodyParams = new HashMap<>();
}
try {
requestType = HttpRequestMethod.valueOf(paramsMap.get(HttpAlertConstants.NAME_REQUEST_TYPE));
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("requestType is not a valid value");
}
contentType = OkHttpRequestHeaderContentType.fromValue(paramsMap.get(HttpAlertConstants.NAME_CONTENT_TYPE));
if (contentType == null) {
throw new IllegalArgumentException("contentType is not a valid value");
}
timeout = (StringUtils.isNotBlank(paramsMap.get(HttpAlertConstants.NAME_TIMEOUT))
? Integer.parseInt(paramsMap.get(HttpAlertConstants.NAME_TIMEOUT))View on GitHub (pinned to 02eac45a1b)
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.
Example fix
// before
bodyParams=key1=value1&key2=value2
// after
bodyParams={"key1":"value1","key2":"value2"} Defensive patterns
Strategy: validation
Validate before calling
String bp = paramsMap.get("bodyParams");
if (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"); } } Type guard
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; } } Try / catch
try { new HttpAlert(paramsMap); } catch (IllegalArgumentException e) { log.error("invalid bodyParams json", e); } Prevention
- Use a JSON object for bodyParams, not form-urlencoded strings
- Lint the JSON before saving the alert config
- Omit bodyParams when unused
When it happens
Trigger: bodyParams contains non-JSON text, a JSON array/scalar where an object is required, or trailing commas/invalid escapes.
Common situations: Sending form-style 'key=value&k2=v2' body instead of a JSON object; shell quoting mangling double quotes when saving params.
Understand the failure class
Background: JSON parse error: "Unexpected token" / "not valid JSON" / "failed to parse" — what JSON parsers are really complaining about — this error's family across 45 libraries.
Related errors
- headerParams is not a valid json
- url can not be null
- requestType is not a valid value
- Sagemaker task params is empty
- itemsList is null
AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06).
Data as JSON: /api/errors/845dbf886889a927.
Report an issue: GitHub.