apache/dolphinscheduler · error · IllegalArgumentException
contentType is not a valid value
Error message
contentType is not a valid value
What it means
paramsValidator resolves contentType via OkHttpRequestHeaderContentType.fromValue; if the value is not a known content type, fromValue returns null and IllegalArgumentException('contentType is not a valid value') is thrown.
Source
Thrown at dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpSender.java:91
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))
: HttpAlertConstants.DEFAULT_TIMEOUT) * 1000;
}
AlertResult send(String msg) {
AlertResult alertResult = new AlertResult();
OkHttpResponse okHttpResponse;
try {
okHttpResponse = sendHttpRequest(msg);
} catch (RuntimeException e) {
throw new RuntimeException(e);
}
View on GitHub (pinned to 02eac45a1b)
Solutions
- Set contentType to one of the values supported by OkHttpRequestHeaderContentType in your version (e.g. the JSON content type constant).
- Check the enum source in your DolphinScheduler version for the exact accepted strings.
- Upgrade if a needed content type was added in a newer release.
Example fix
// before contentType=text/html // after contentType=application/json
Defensive patterns
Strategy: validation
Validate before calling
String ct = paramsMap.get("contentType");
if (OkHttpRequestHeaderContentType.fromValue(ct) == null) throw new IllegalArgumentException("unsupported contentType: " + ct); Try / catch
try { new HttpAlert(paramsMap); } catch (IllegalArgumentException e) { log.error("invalid contentType", e); } Prevention
- Use a content type value supported by OkHttpRequestHeaderContentType
- Consult the enum source for exact accepted strings
- Prefer the UI dropdown values over free-text MIME types
When it happens
Trigger: contentType param is absent or set to a string not matching any OkHttpRequestHeaderContentType constant (e.g. 'application/x-www-form-urlencoded' when only JSON/other fixed values are supported).
Common situations: User enters a full MIME type that the enum does not define; contentType field left empty while sending a JSON body.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- requestType is not a valid value
- url can not be null
- headerParams is not a valid json
- bodyParams is not a valid json
- http request method %s not supported
AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06).
Data as JSON: /api/errors/d0590d45481e41f9.
Report an issue: GitHub.