FasterXML/jackson-databind · error · IllegalArgumentException
argument "%s" is null
Error message
argument "%s" is null
What it means
ObjectReader._assertNotNull() is a precondition guard invoked by nearly every read/forType/readValue/readTree/etc. entry point (57 call sites) to fail fast with a clear message when a required argument is null. The message includes the parameter name (e.g. "src", "content", "p", "type") so you know exactly which argument was null. It replaces a latent NullPointerException deeper in the call with an explicit, descriptive IllegalArgumentException at the API boundary.
Source
Thrown at src/main/java/tools/jackson/databind/ObjectReader.java:2115
}
/**
* Internal helper method called to create an instance of {@link DeserializationContext}
* for deserializing a single root value.
* Can be overridden if a custom context is needed.
*/
protected DeserializationContextExt _deserializationContext() {
return _contexts.createContext(_config, _schema, _injectableValues);
}
protected DeserializationContextExt _deserializationContext(JsonParser p) {
return _contexts.createContext(_config, _schema, _injectableValues)
.assignParser(p);
}
protected final void _assertNotNull(String paramName, Object src) {
if (src == null){
throw new IllegalArgumentException("argument \"%s\" is null".formatted(paramName));
}
}
/*
/**********************************************************************
/* Helper methods, locating deserializers etc
/**********************************************************************
*/
/**
* Method called to locate deserializer for the passed root-level value.
*/
protected ValueDeserializer<Object> _findRootDeserializer(DeserializationContext ctxt)
throws DatabindException
{
if (_rootDeserializer != null) {
return _rootDeserializer;
}View on GitHub (pinned to a50c7d2a1d)
Solutions
- Check for null before calling read methods: Objects.requireNonNull(src, "src") or an explicit if/null branch.
- If null is legitimately 'no input', handle it at the caller with an empty/Optional/default rather than passing it down.
- Annotate the producing method/field with @NotNull / @NonNull and enable static null-analysis (Checker Framework, IntelliJ nullability, Eclipse null annotations).
- Where the value comes from a Map or external source, use getOrDefault / Optional.ofNullable to guarantee non-null.
Example fix
// before
String body = request.getBody(); // may be null
MyType v = reader.readValue(body); // throws: argument "src" is null
// after
String body = request.getBody();
if (body == null) throw new BadRequestException("body required");
MyType v = reader.readValue(body); Defensive patterns
Strategy: validation
Validate before calling
String body = ...;
if (body == null) throw new IllegalArgumentException("src must not be null");
reader.readValue(body); Type guard
// simple non-null check is the guard; for collections, check emptiness too
Try / catch
try {
return reader.readValue(src);
} catch (IllegalArgumentException e) {
if (e.getMessage().endsWith("is null")) {
// provide a domain-meaningful default or 4xx response
}
throw e;
} Prevention
- Null-check at the controller/service boundary before calling read methods.
- Use Optional and serialize only when present.
- Enable static null analysis (@NonNull annotations) to catch null flows at compile time.
- Prefer Objects.requireNonNull(src, "src") for clear precondition failures.
When it happens
Trigger: Calling reader.readValue((String)null), reader.readTree((JsonParser)null), reader.forType((Class)null), reader.readValues((InputStream)null), etc. Common when the source variable comes from a map.get() that returned null, a resource lookup that failed, or a generically-typed parameter that the caller left null.
Common situations: A field/property that was optional in the source data but is passed unchecked; a Spring/Hazelcast/JNDI resource lookup returning null on misconfiguration and being forwarded directly; HTTP request body or path variable that is null when the endpoint receives no body; refactoring that moved a null check away from the call site.
Related errors
- argument "{}" is null
- Only support `JavaType` implementation of `ResolvedType`, no
- maxProblems must be positive
- Cannot use FormatSchema of type {} for format {}
- Cannot pass null Deserializers
AI-assisted analysis of FasterXML/jackson-databind@a50c7d2a1d (2026-08-06).
Data as JSON: /api/errors/df281cda030727c9.
Report an issue: GitHub.