jhy/jsoup · error · ValidationException
The ' ' parameter must not be empty.
Error message
The '%s' parameter must not be empty.
What it means
jsoup's Validate.notEmptyParam is a precondition check that throws a ValidationException when a caller passes null or an empty ('' length 0) string as a named method parameter. The message names the offending parameter so the caller can locate the bad argument. It is jsoup's way of failing fast on empty required String inputs instead of propagating confusing downstream behavior.
Solutions
- Check the named parameter in the message at the call site and supply a non-null, non-empty value.
- Guard your own input: if(empty(s)) throw before calling the jsoup API.
- If empty is legitimate in your domain, substitute a sensible default before calling.
- If you believe empty should be allowed, file/inspect jsoup issue — this check is a library precondition, not a transient failure.
Example fix
// before Document doc = Jsoup.parse(html, ""); // if baseUri empty // after if (baseUri == null || baseUri.isEmpty()) baseUri = "about:blank"; Document doc = Jsoup.parse(html, baseUri);
Defensive patterns
Strategy: validation
Validate before calling
if (param == null || param.isEmpty()) throw new IllegalArgumentException("'param' must not be empty before calling jsoup"); Type guard
boolean isPresent(String s) { return s != null && !s.isEmpty(); } Try / catch
try { jsoupCall(value); } catch (org.jsoup.helper.ValidationException e) { log.error("Missing required string parameter: {}", e.getMessage()); } Prevention
- Never pass "" as a default for required string parameters; use null + explicit check or Optional.
- Trim user/config input and reject blank values before calling jsoup.
- Centralize a requireNonEmpty(String, String) helper in your codebase.
When it happens
Trigger: Any public jsoup API whose implementation calls Validate.notEmptyParam(string, param) and receives null or "" — e.g. passing an empty string as an attribute name, element tag, selector, or other required string parameter.
Common situations: Building a document from config or user input where a field is empty; variables initialized to "" as a default and then passed to jsoup; reading values from properties/JSON where a key exists but maps to empty; refactors that drop null checks without noticing empty strings also fail.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- Object must not be null
- The parameter ' ' must not be null.
- msg
- String must not be empty
- Pattern syntax error:
AI-assisted analysis of jhy/jsoup@9851ac5d9c (2026-09-08).
Data as JSON: /api/errors/26e5a53f57025943.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/org/jsoup/helper/Validate.java:156
/**
* Validates that the string is not null and is not empty
* @param string the string to test
* @throws ValidationException if the string is null or empty
*/
public static void notEmpty(@Nullable String string) {
if (string == null || string.length() == 0)
throw new ValidationException("String must not be empty");
}
/**
Validates that the string parameter is not null and is not empty
* @param string the string to test
* @param param the name of the parameter, for presentation in the validation exception.
* @throws ValidationException if the string is null or empty
*/
public static void notEmptyParam(@Nullable final String string, final String param) {
if (string == null || string.length() == 0)
throw new ValidationException(String.format("The '%s' parameter must not be empty.", param));
}
/**
* Validates that the string is not null and is not empty
* @param string the string to test
* @param msg message to include in the Exception if validation fails
* @throws ValidationException if the string is null or empty
*/
public static void notEmpty(@Nullable String string, String msg) {
if (string == null || string.length() == 0)
throw new ValidationException(msg);
}
/**
* Blow up if we reach an unexpected state.
* @param msg message to think about
* @throws IllegalStateException if we reach this state
*/View on GitHub (pinned to 9851ac5d9c)