{"record":{"id":"068d0f8d575f6e25","repo":"jhy/jsoup","slug":"the-parameter-s-must-not-be-null","errorCode":null,"errorMessage":"The parameter '%s' must not be null.","messagePattern":"The parameter '(.+?)' must not be null\\.","errorType":"validation","errorClass":"ValidationException","httpStatus":null,"severity":"error","filePath":"src/main/java/org/jsoup/helper/Validate.java","lineNumber":31,"sourceCode":"     * Validates that the object is not null\n     * @param obj object to test\n     * @throws ValidationException if the object is null\n     */\n    public static void notNull(@Nullable Object obj) {\n        if (obj == null)\n            throw new ValidationException(\"Object must not be null\");\n    }\n\n    /**\n     Validates that the parameter is not null\n\n     * @param obj the parameter to test\n     * @param param the name of the parameter, for presentation in the validation exception.\n     * @throws ValidationException if the object is null\n     */\n    public static void notNullParam(@Nullable final Object obj, final String param) {\n        if (obj == null)\n            throw new ValidationException(String.format(\"The parameter '%s' must not be null.\", param));\n    }\n\n    /**\n     * Validates that the object is not null\n     * @param obj object to test\n     * @param msg message to include in the Exception if validation fails\n     * @throws ValidationException if the object is null\n     */\n    public static void notNull(@Nullable Object obj, String msg) {\n        if (obj == null)\n            throw new ValidationException(msg);\n    }\n\n    /**\n     Verifies the input object is not null, and returns that object, maintaining its type. Effectively this casts a\n     nullable object to a non-null object.\n\n     @param obj nullable object to cast to not-null","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/jhy/jsoup/blob/9851ac5d9c576c6888910b5a51a2362bbc978959/src/main/java/org/jsoup/helper/Validate.java#L13-L49","documentation":"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.","triggerScenarios":"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.","commonSituations":"Nullable values from maps, config files, or databases passed straight into API calls; method parameters forwarded from an upstream caller without re-checking.","solutions":["Null-check the value at the boundary and substitute a sensible default or abort early","Read the parameter name in the message to locate the failing argument quickly","Validate inputs once at your API's entry point rather than deep in call chains"],"exampleFix":"// before\nparse(input.getCharset(), null); // param 'charset' is null\n// after\nObjects.requireNonNull(input.getCharset(), \"charset\");\nparse(input.getCharset(), baseUri);","handlingStrategy":"validation","validationCode":"if (param == null) {\n    throw new IllegalArgumentException(\"Parameter 'charset' must not be null\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    apiCall(value);\n} catch (ValidationException e) {\n    if (e.getMessage().startsWith(\"The parameter\")) {\n        // message names the offending parameter; log and fix call site\n    } else { throw e; }\n}","preventionTips":["Validate named parameters at your entry points before delegating to jsoup","Substitute defaults for optional values instead of passing null","Read the parameter name in the exception message to locate the failing argument"],"tags":["null-check","validation","parameters"],"backgroundTag":"null-argument","analyzedSha":"9851ac5d9c576c6888910b5a51a2362bbc978959","analyzedAt":"2026-09-08T15:22:04.931Z","contentChangedAt":"2026-09-08T15:22:04.931Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}