{"record":{"id":"af295d841b9a97f9","repo":"FasterXML/jackson-databind","slug":"should-not-call-set-on-objectidproperty-that-has","errorCode":null,"errorMessage":"Should not call set() on ObjectIdProperty that has no SettableBeanProperty","messagePattern":"Should not call set\\(\\) on ObjectIdProperty that has no SettableBeanProperty","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"src/main/java/tools/jackson/databind/deser/impl/ObjectIdValueProperty.java","lineNumber":150,"sourceCode":"            if (idProp.isCreatorProperty()) {\n                return instance;\n            }\n            return idProp.setAndReturn(ctxt, instance, id);\n        }\n        return instance;\n    }\n\n    @Override\n    public void set(DeserializationContext ctxt,Object instance, Object value) {\n        setAndReturn(ctxt, instance, value);\n    }\n\n    @Override\n    public Object setAndReturn(DeserializationContext ctxt, Object instance, Object value)\n    {\n        SettableBeanProperty idProp = _objectIdReader.idProperty;\n        if (idProp == null) {\n            throw new UnsupportedOperationException(\n                    \"Should not call set() on ObjectIdProperty that has no SettableBeanProperty\");\n        }\n        // [databind#4729] Records/Creators do not have setters, skip\n        if (idProp.isCreatorProperty()) {\n            return instance;\n        }\n        return idProp.setAndReturn(ctxt, instance, value);\n    }\n}\n","sourceCodeStart":132,"sourceCodeEnd":160,"githubUrl":"https://github.com/FasterXML/jackson-databind/blob/87876ca5c0569b4933aec2d30d6225e4b9ba3a43/src/main/java/tools/jackson/databind/deser/impl/ObjectIdValueProperty.java#L132-L160","documentation":"ObjectIdValueProperty.setAndReturn/set delegates to an underlying SettableBeanProperty obtained from ObjectIdReader; if that property is null (the ObjectIdReader was constructed without an idProperty), there is no target to receive the id value, and the call is rejected. This typically indicates a misconfigured ObjectIdReader or a code path that should not call set on an id-only property.","triggerScenarios":"Constructing an ObjectIdReader with a null idProperty (e.g. custom resolver wiring); framework code that calls set()/setAndReturn() on an ObjectIdValueProperty whose backing SettableBeanProperty was never set; immutability/records path where the id is bound via the creator and set() should be a no-op.","commonSituations":"Custom ObjectIdReader construction; Jackson internals calling set() on an id property that only participates in creator binding; record types where @JsonIdentityInfo id flows through the constructor (the isCreatorProperty guard returns early, but if idProperty is null even that path throws).","solutions":["Build ObjectIdReader with a non-null SettableBeanProperty (use ObjectIdReader.create with the proper idProperty).","If the id is bound through a creator parameter (record/builder), ensure idProperty.isCreatorProperty() returns true so set() short-circuits before reaching the null guard.","Avoid calling set() on ObjectIdValueProperty directly in custom code; rely on the framework's binding."],"exampleFix":"// before\nObjectIdReader reader = ObjectIdReader.construct(type, propName, gen, resolver, null, false);\n// idProperty null -> set() throws later\n\n// after\nSettableBeanProperty idProp = ...; // real property for the id\nObjectIdReader reader = ObjectIdReader.construct(type, propName, gen, resolver, idProp, false);","handlingStrategy":"validation","validationCode":"ObjectIdReader reader = ...;\nif (reader.idProperty == null) {\n    throw new IllegalStateException(\"ObjectIdReader needs a non-null idProperty\");\n}","typeGuard":"static boolean hasIdProperty(ObjectIdReader r) {\n    return r != null && r.idProperty != null;\n}","tryCatchPattern":"try { idProp.set(ctxt, bean, value); }\ncatch (UnsupportedOperationException e) {\n    if (e.getMessage().contains(\"no SettableBeanProperty\")) {\n        // build ObjectIdReader with a real idProperty\n    } else throw e;\n}","preventionTips":["Always construct ObjectIdReader with a non-null SettableBeanProperty for the id.","For records/builders, ensure the id property is a creator property so set() short-circuits."],"tags":["deserialization","object-identity","configuration","internal"],"backgroundTag":null,"analyzedSha":"87876ca5c0569b4933aec2d30d6225e4b9ba3a43","analyzedAt":"2026-08-11T12:55:24.033Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}