{"record":{"id":"aa5448cffe307e30","repo":"FasterXML/jackson-databind","slug":"cannot-pass-null-resolver","errorCode":null,"errorMessage":"Cannot pass null resolver","messagePattern":"Cannot pass null resolver","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/tools/jackson/databind/cfg/DeserializerFactoryConfig.java","lineNumber":145,"sourceCode":"        ValueDeserializerModifier[] all = ArrayBuilders.insertInListNoDup(_modifiers, modifier);\n        return new DeserializerFactoryConfig(_additionalDeserializers, _additionalKeyDeserializers,\n                all, _valueInstantiators);\n    }\n\n    /**\n     * Fluent/factory method used to construct a configuration object that\n     * has same configuration as this instance plus specified additional\n     * value instantiator provider object.\n     * Added instantiator provider has the highest priority (that is, it\n     * gets called before any already registered resolver).\n     *\n     * @param instantiators Object that can provide {@link tools.jackson.databind.deser.ValueInstantiator}s for\n     *    constructing POJO values during deserialization\n     */\n    public DeserializerFactoryConfig withValueInstantiators(ValueInstantiators instantiators)\n    {\n        if (instantiators == null) {\n            throw new IllegalArgumentException(\"Cannot pass null resolver\");\n        }\n        ValueInstantiators[] all = ArrayBuilders.insertInListNoDup(_valueInstantiators, instantiators);\n        return new DeserializerFactoryConfig(_additionalDeserializers, _additionalKeyDeserializers,\n                _modifiers, all);\n    }\n\n    public boolean hasDeserializers() { return _additionalDeserializers.length > 0; }\n\n    public boolean hasKeyDeserializers() { return _additionalKeyDeserializers.length > 0; }\n\n    public boolean hasDeserializerModifiers() { return _modifiers.length > 0; }\n\n    public boolean hasValueInstantiators() { return _valueInstantiators.length > 0; }\n\n    public Iterable<Deserializers> deserializers() {\n        return new ArrayIterator<Deserializers>(_additionalDeserializers);\n    }\n","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/FasterXML/jackson-databind/blob/a50c7d2a1d57234ac4adf70dbd88ac90db6436e4/src/main/java/tools/jackson/databind/cfg/DeserializerFactoryConfig.java#L127-L163","documentation":"DeserializerFactoryConfig.withValueInstantiators(ValueInstantiators) registers a provider of custom ValueInstantiators (used to override how POJOs are constructed). It rejects null with a clear message; passing null would break the instantiator-resolution chain inside BeanDeserializerFactory. Note the message says 'resolver' (the internal term) while the parameter/type is ValueInstantiators.","triggerScenarios":"Calling config.withValueInstantiators(null); a module registering instantiators conditionally and forwarding null; a DI-provided ValueInstantiators bean that is null because a dependency (e.g. a factory) is missing.","commonSituations":"Custom entity/record instantiation via a module where the instantiator is built from optional deps; Spring bean for ValueInstantiators absent; refactoring that left a null field plumbed into registration; mixing up the parameter name 'instantiators' with the message term 'resolver' and assuming a different argument is at fault.","solutions":["Guard registration: if (vi != null) cfg.withValueInstantiators(vi).","Ensure the ValueInstantiators and its underlying ValueInstantiator factory are non-null (inject eagerly).","Filter nulls when registering a list of instantiator providers.","If no custom instantiation is needed, simply don't register rather than registering null."],"exampleFix":"// before\nValueInstantiators vi = customInst ? new MyInstantiators(beanFactory) : null;\ncfg.withValueInstantiators(vi); // throws\n// after\nValueInstantiators vi = customInst ? new MyInstantiators(beanFactory) : null;\nif (vi != null) cfg.withValueInstantiators(vi);","handlingStrategy":"validation","validationCode":"ValueInstantiators vi = ...;\nif (vi == null) throw new IllegalArgumentException(\"ValueInstantiators must not be null\");\ncfg.withValueInstantiators(vi);","typeGuard":"// non-null reference check","tryCatchPattern":"try {\n    cfg.withValueInstantiators(vi);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().equals(\"Cannot pass null resolver\")) {\n        // note: message says 'resolver', argument is 'instantiators'\n    }\n    throw e;\n}","preventionTips":["Guard conditional instantiator registration; inject eagerly.","Note the message text 'resolver' refers to the ValueInstantiators argument.","Filter nulls from instantiator provider lists."],"tags":["module","value-instantiator","factory-config","null-check","configuration"],"analyzedSha":"a50c7d2a1d57234ac4adf70dbd88ac90db6436e4","analyzedAt":"2026-08-06T20:31:51.404Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}