FasterXML/jackson-databind · error · IllegalArgumentException
Cannot pass null property name
Error message
Cannot pass null property name
What it means
BeanPropertyMap.findDefinition rejects a null property name with IllegalArgumentException. It is a construction-time lookup that does no case-insensitive matching or alias expansion, and a null key has no defined behavior, so it fails fast.
Solutions
- Null-check the key before calling findDefinition; skip or use a sentinel instead.
- Ensure all SettableBeanProperty instances have non-null names at construction.
- If a name is genuinely optional, use an empty string rather than null.
Example fix
// before SettableBeanProperty p = map.findDefinition(maybeNullName); // throws if null // after SettableBeanProperty p = (maybeNullName != null) ? map.findDefinition(maybeNullName) : null;
Defensive patterns
Strategy: validation
Validate before calling
if (name == null) {
throw new IllegalArgumentException("name required");
}
return map.findDefinition(name); Type guard
static boolean isNonEmptyName(String n) { return n != null && !n.isEmpty(); } Try / catch
try { map.findDefinition(name); }
catch (IllegalArgumentException e) {
if (e.getMessage().equals("Cannot pass null property name")) {
// guard upstream against null names
} else throw e;
} Prevention
- Null-check external inputs before lookup.
- Never construct SettableBeanProperty with a null name; use empty string if name is optional.
When it happens
Trigger: Calling findDefinition(null) from custom factory/introspection code; a property whose getName() returns null being passed through; reflective code that strips names during property processing.
Common situations: Custom modules or mixins that produce a SettableBeanProperty with a null name; bugs in third-party libraries that call findDefinition with an unguarded external value; unit tests probing the map with arbitrary input.
Related errors
- deserialization problems (showing first 5):%n
- maxProblems must be positive, was
- No entry ' ' found, can't replace
- Trying to resolve a forward reference with id
- AnnotationIntrospector returned `Class<
AI-assisted analysis of FasterXML/jackson-databind@87876ca5c0 (2026-08-11).
Data as JSON: /api/errors/a25c9a58a23ad66e.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/tools/jackson/databind/deser/bean/BeanPropertyMap.java:419
public SettableBeanProperty findDefinition(int index)
{
for (SettableBeanProperty prop : _propsInOrder) {
if ((prop != null) && (index == prop.getPropertyIndex())) {
return prop;
}
}
return null;
}
/**
* NOTE: does NOT do case-insensitive matching -- only to be used during construction
* and never during deserialization process -- nor alias expansion.
*/
public SettableBeanProperty findDefinition(String key)
{
if (key == null) {
throw new IllegalArgumentException("Cannot pass null property name");
}
for (SettableBeanProperty prop : _propsInOrder) {
if (key.equals(prop.getName())) {
return prop;
}
}
return null;
}
/*
/**********************************************************************
/* Std method overrides
/**********************************************************************
*/
@Override
public String toString()
{View on GitHub (pinned to 87876ca5c0)