{"record":{"id":"c8f41231277f9611","repo":"FasterXML/jackson-databind","slug":"could-not-resolve-object-id-id-for-beanty","errorCode":null,"errorMessage":"Could not resolve Object Id [${id}] (for ${_beanType}).","messagePattern":"Could not resolve Object Id \\[(.+?)\\] \\(for (.+?)\\)\\.","errorType":"exception","errorClass":"UnresolvedForwardReference","httpStatus":null,"severity":"error","filePath":"src/main/java/tools/jackson/databind/deser/bean/BeanDeserializerBase.java","lineNumber":1653,"sourceCode":"    protected Object deserializeWithObjectId(JsonParser p, DeserializationContext ctxt)\n        throws JacksonException\n    {\n        return deserializeFromObject(p, ctxt);\n    }\n\n    /**\n     * Method called in cases where it looks like we got an Object Id\n     * to parse and use as a reference.\n     */\n    protected Object deserializeFromObjectId(JsonParser p, DeserializationContext ctxt)\n        throws JacksonException\n    {\n        Object id = _objectIdReader.readObjectReference(p, ctxt);\n        ReadableObjectId roid = ctxt.findObjectId(id, _objectIdReader.generator, _objectIdReader.resolver);\n        // do we have it resolved?\n        Object pojo = roid.resolve();\n        if (pojo == null) { // not yet; should wait...\n            throw new UnresolvedForwardReference(p,\n                    \"Could not resolve Object Id [\"+id+\"] (for \"+_beanType+\").\",\n                    p.currentLocation(), roid);\n        }\n        return pojo;\n    }\n\n    protected Object deserializeFromObjectUsingNonDefault(JsonParser p,\n            DeserializationContext ctxt)\n        throws JacksonException\n    {\n        // 02-Jul-2024, tatu: [databind#4602] Need to tweak regular and \"array\" delegating\n        //   Creator handling\n        final ValueDeserializer<Object> delegateDeser = _delegateDeserializer(p);\n        if (delegateDeser != null) {\n            // [databind#5909]: signal delegate-bind-pending so that any ROID\n            // bound during delegate deserialization retains resolved Referrings\n            // — needed for collection-property forward refs to be rebound after\n            // updateObjectId(delegate, bean) below.","sourceCodeStart":1635,"sourceCodeEnd":1671,"githubUrl":"https://github.com/FasterXML/jackson-databind/blob/87876ca5c0569b4933aec2d30d6225e4b9ba3a43/src/main/java/tools/jackson/databind/deser/bean/BeanDeserializerBase.java#L1635-L1671","documentation":"Thrown as an UnresolvedForwardReference when a JSON Object Id referenced in the input could not be resolved by the end of deserialization. With @JsonIdentityInfo, an @id with no preceding object definition leaves a pending forward reference; Jackson raises this when it tries to materialize the referenced object but the resolver has no entry.","triggerScenarios":"JSON contains {\"@id\":99,\"@ref\":99} where the referenced object was never defined; circular references serialized with an incompatible identity scheme; deserializing a fragment that references an object defined elsewhere in a stream that was not parsed; custom ObjectIdResolver that does not retain objects.","commonSituations":"Mixing serialized output from one mapper version/config with a reader configured differently; truncated JSON; custom ObjectIdResolver with a scope that discards resolved items; @JsonIdentityInfo on bidirectional entities where only one side was serialized.","solutions":["Ensure the JSON was serialized with the same @JsonIdentityInfo (generator/resolver/property name) as the reader.","If forward references are legitimate, catch UnresolvedForwardReference and resolve them after the fact via handleResolvedForwardReference.","Provide a custom ObjectIdResolver (scope=SCOPE_SINGLETON or a custom implementation) that retains resolved objects across the stream.","Check for truncated/malformed JSON where the referenced object definition is missing."],"exampleFix":"// before\n@JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class)\nclass Node { Node next; } // reading JSON whose @ref has no object -> throws\n\n// after (ensure writer used same scheme, or resolve manually)\ntry {\n    Node n = mapper.readValue(json, Node.class);\n} catch (UnresolvedForwardReference e) {\n    ReadableObjectId roid = e.getRoid();\n    roid.bindItem(fallbackObject);\n}","handlingStrategy":"try-catch","validationCode":"// before reading, confirm the resolver can answer; generally not possible\n// pre-validate by ensuring writer config matches reader @JsonIdentityInfo","typeGuard":"// no compile-time guard; identity references are runtime-resolved","tryCatchPattern":"try { mapper.readValue(json, Node.class); }\ncatch (UnresolvedForwardReference e) {\n    ReadableObjectId roid = e.getRoid();\n    // supply the missing object or report the dangling @id\n}","preventionTips":["Use identical @JsonIdentityInfo on both writer and reader.","For optional references, provide a custom ObjectIdResolver with sensible defaults.","Validate the JSON stream is complete (no missing object definitions)."],"tags":["deserialization","object-identity","forward-reference","configuration"],"backgroundTag":null,"analyzedSha":"87876ca5c0569b4933aec2d30d6225e4b9ba3a43","analyzedAt":"2026-08-11T12:55:24.033Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}