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

  1. Set contentType to one of the values supported by OkHttpRequestHeaderContentType in your version (e.g. the JSON content type constant).
  2. Check the enum source in your DolphinScheduler version for the exact accepted strings.
  3. 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

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


AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06). Data as JSON: /api/errors/d0590d45481e41f9. Report an issue: GitHub.