{"record":{"id":"65fb2f8f36066349","repo":"FasterXML/jackson-databind","slug":"cannot-call-withvaluedeserializer-on","errorCode":null,"errorMessage":"Cannot call withValueDeserializer() on {}","messagePattern":"Cannot call withValueDeserializer\\(\\) on (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"src/main/java/tools/jackson/databind/deser/SettableAnyProperty.java","lineNumber":526,"sourceCode":"        // Let's override since this is much simpler with JsonNodes\n        @Override\n        public Object deserialize(JsonParser p, DeserializationContext ctxt)\n            throws JacksonException\n        {\n            return _valueDeserializer.deserialize(p, ctxt);\n        }\n\n        @Override\n        protected void _set(DeserializationContext ctxt, Object instance, Object propName, Object value)\n            throws Exception\n        {\n            ((ObjectNode) instance).set((String) propName, (JsonNode) value);\n        }\n\n        // Should not get called but...\n        @Override\n        public SettableAnyProperty withValueDeserializer(ValueDeserializer<Object> deser) {\n            throw new UnsupportedOperationException(\"Cannot call withValueDeserializer() on \" + getClass().getName());\n        }\n\n        @Override\n        public int getParameterIndex() { return _parameterIndex; }\n\n        @Override\n        public Object createParameterObject() { return _nodeFactory.objectNode(); }\n    }\n}\n","sourceCodeStart":508,"sourceCodeEnd":536,"githubUrl":"https://github.com/FasterXML/jackson-databind/blob/a50c7d2a1d57234ac4adf70dbd88ac90db6436e4/src/main/java/tools/jackson/databind/deser/SettableAnyProperty.java#L508-L536","documentation":"Thrown when withValueDeserializer() is called on a JsonNodeParameterAnyProperty instance. This subclass (used for @JsonAnySetter on a creator parameter that targets a JsonNode/ObjectNode) deliberately throws UnsupportedOperationException because it cannot meaningfully accept a different value deserializer — the node-based any-setter serializes raw JsonNode content and does not delegate to a ValueDeserializer. The base class marks this as 'Should not get called but...' indicating it is a defensive guard against framework misuse.","triggerScenarios":"Defining @JsonAnySetter on a creator constructor parameter whose type is ObjectNode/JsonNode, combined with a custom deserializer or module that attempts contextualization via withValueDeserializer(). Subclassing SettableAnyProperty and routing through the JsonNodeParameterAnyProperty path while the framework attempts contextualizer replacement.","commonSituations":"Using a custom DeserializerFactory or BeanDeserializerModifier that calls withValueDeserializer on all any-properties indiscriminately. Mixing @JsonAnySetter with @JsonCreator on an ObjectNode-typed parameter while also registering a custom value deserializer.","solutions":["Avoid annotating ObjectNode/JsonNode creator parameters with @JsonAnySetter if a custom value deserializer is required.","In any custom factory/modifier code, check the concrete SettableAnyProperty type before calling withValueDeserializer (skip JsonNodeParameterAnyProperty).","Use a Map<String,Object> parameter type instead of ObjectNode if you need custom per-value deserialization on any-setter content.","Register the custom deserializer at the module level so it is already resolved during construction rather than via contextual replacement."],"exampleFix":"// before\n@JsonCreator\npublic MyBean(@JsonAnySetter ObjectNode extra) { ... }\n// factory calls withValueDeserializer -> throws\n\n// after: use Map if custom deser needed, or don't customize\n@JsonCreator\npublic MyBean(@JsonAnySetter Map<String,Object> extra) { ... }","handlingStrategy":"type-guard","validationCode":"// Check type before calling withValueDeserializer\nif (!(settableAnyProp instanceof SettableAnyProperty.JsonNodeParameterAnyProperty)) {\n    settableAnyProp = settableAnyProp.withValueDeserializer(deser);\n}","typeGuard":"static boolean canReplaceDeserializer(SettableAnyProperty prop) {\n    return !(prop.getClass().getName().contains(\"JsonNodeParameterAnyProperty\"));\n}","tryCatchPattern":"try {\n    prop = prop.withValueDeserializer(deser);\n} catch (UnsupportedOperationException e) {\n    // JsonNodeParameterAnyProperty cannot be contextualized — skip\n}","preventionTips":["Avoid @JsonAnySetter on ObjectNode/JsonNode creator parameters when custom deserializers are involved.","Use Map<String,Object> instead of ObjectNode for any-setter with custom deser.","Guard custom factory code against unsupported any-property types."],"tags":["jackson","deserialization","any-setter","unsupported-operation","creator-parameter"],"analyzedSha":"a50c7d2a1d57234ac4adf70dbd88ac90db6436e4","analyzedAt":"2026-08-06T20:31:51.404Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}