jhy/jsoup · error · ValidationException

The parameter ' ' must not be null.

Error message

The parameter '%s' must not be null.

What it means

Validate.notNullParam(obj, param) is the parameter-named variant of the null assertion: when the tested object is null it throws a ValidationException formatted as "The parameter '<param>' must not be null.", naming the offending parameter for easier debugging.

Solutions

  1. Null-check the value at the boundary and substitute a sensible default or abort early
  2. Read the parameter name in the message to locate the failing argument quickly
  3. Validate inputs once at your API's entry point rather than deep in call chains

Example fix

// before
parse(input.getCharset(), null); // param 'charset' is null
// after
Objects.requireNonNull(input.getCharset(), "charset");
parse(input.getCharset(), baseUri);
Defensive patterns

Strategy: validation

Validate before calling

if (param == null) {
    throw new IllegalArgumentException("Parameter 'charset' must not be null");
}

Try / catch

try {
    apiCall(value);
} catch (ValidationException e) {
    if (e.getMessage().startsWith("The parameter")) {
        // message names the offending parameter; log and fix call site
    } else { throw e; }
}

Prevention

When it happens

Trigger: Calling a jsoup (or your own) method that validates a named parameter with notNullParam and passing null for that parameter — e.g. a null charset name, null baseUri, or null element argument whose parameter name is embedded in the error.

Common situations: Nullable values from maps, config files, or databases passed straight into API calls; method parameters forwarded from an upstream caller without re-checking.

Related errors


AI-assisted analysis of jhy/jsoup@9851ac5d9c (2026-09-08). Data as JSON: /api/errors/068d0f8d575f6e25. Report an issue: GitHub.

Appendix: source

Thrown at src/main/java/org/jsoup/helper/Validate.java:31

     * Validates that the object is not null
     * @param obj object to test
     * @throws ValidationException if the object is null
     */
    public static void notNull(@Nullable Object obj) {
        if (obj == null)
            throw new ValidationException("Object must not be null");
    }

    /**
     Validates that the parameter is not null

     * @param obj the parameter to test
     * @param param the name of the parameter, for presentation in the validation exception.
     * @throws ValidationException if the object is null
     */
    public static void notNullParam(@Nullable final Object obj, final String param) {
        if (obj == null)
            throw new ValidationException(String.format("The parameter '%s' must not be null.", param));
    }

    /**
     * Validates that the object is not null
     * @param obj object to test
     * @param msg message to include in the Exception if validation fails
     * @throws ValidationException if the object is null
     */
    public static void notNull(@Nullable Object obj, String msg) {
        if (obj == null)
            throw new ValidationException(msg);
    }

    /**
     Verifies the input object is not null, and returns that object, maintaining its type. Effectively this casts a
     nullable object to a non-null object.

     @param obj nullable object to cast to not-null

View on GitHub (pinned to 9851ac5d9c)