{"record":{"id":"a25c9a58a23ad66e","repo":"FasterXML/jackson-databind","slug":"cannot-pass-null-property-name","errorCode":null,"errorMessage":"Cannot pass null property name","messagePattern":"Cannot pass null property name","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/tools/jackson/databind/deser/bean/BeanPropertyMap.java","lineNumber":419,"sourceCode":"\n    public SettableBeanProperty findDefinition(int index)\n    {\n        for (SettableBeanProperty prop : _propsInOrder) {\n            if ((prop != null) && (index == prop.getPropertyIndex())) {\n                return prop;\n            }\n        }\n        return null;\n    }\n\n    /**\n     * NOTE: does NOT do case-insensitive matching -- only to be used during construction\n     * and never during deserialization process -- nor alias expansion.\n     */\n    public SettableBeanProperty findDefinition(String key)\n    {\n        if (key == null) {\n            throw new IllegalArgumentException(\"Cannot pass null property name\");\n        }\n        for (SettableBeanProperty prop : _propsInOrder) {\n            if (key.equals(prop.getName())) {\n                return prop;\n            }\n        }\n        return null;\n    }\n\n    /*\n    /**********************************************************************\n    /* Std method overrides\n    /**********************************************************************\n     */\n\n    @Override\n    public String toString()\n    {","sourceCodeStart":401,"sourceCodeEnd":437,"githubUrl":"https://github.com/FasterXML/jackson-databind/blob/87876ca5c0569b4933aec2d30d6225e4b9ba3a43/src/main/java/tools/jackson/databind/deser/bean/BeanPropertyMap.java#L401-L437","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nSettableBeanProperty p = map.findDefinition(maybeNullName); // throws if null\n\n// after\nSettableBeanProperty p = (maybeNullName != null) ? map.findDefinition(maybeNullName) : null;","handlingStrategy":"validation","validationCode":"if (name == null) {\n    throw new IllegalArgumentException(\"name required\");\n}\nreturn map.findDefinition(name);","typeGuard":"static boolean isNonEmptyName(String n) { return n != null && !n.isEmpty(); }","tryCatchPattern":"try { map.findDefinition(name); }\ncatch (IllegalArgumentException e) {\n    if (e.getMessage().equals(\"Cannot pass null property name\")) {\n        // guard upstream against null names\n    } else throw e;\n}","preventionTips":["Null-check external inputs before lookup.","Never construct SettableBeanProperty with a null name; use empty string if name is optional."],"tags":["deserialization","bean-property-map","validation","null-argument"],"backgroundTag":null,"analyzedSha":"87876ca5c0569b4933aec2d30d6225e4b9ba3a43","analyzedAt":"2026-08-11T12:55:24.033Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}