{"record":{"id":"4662d89a82b67a41","repo":"FasterXML/jackson-databind","slug":"could-not-resolve-object-id-unresolved-for","errorCode":null,"errorMessage":"Could not resolve Object Id [{}] -- unresolved forward-reference?","messagePattern":"Could not resolve Object Id \\[(.+?)\\] -- unresolved forward-reference\\?","errorType":"exception","errorClass":"UnresolvedForwardReference","httpStatus":null,"severity":"error","filePath":"src/main/java/tools/jackson/databind/deser/AbstractDeserializer.java","lineNumber":315,"sourceCode":"            }\n            break;\n        }\n        return null;\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+\"] -- unresolved forward-reference?\",\n                    p.currentLocation(), roid);\n        }\n        return pojo;\n    }\n}\n","sourceCodeStart":297,"sourceCodeEnd":322,"githubUrl":"https://github.com/FasterXML/jackson-databind/blob/a50c7d2a1d57234ac4adf70dbd88ac90db6436e4/src/main/java/tools/jackson/databind/deser/AbstractDeserializer.java#L297-L322","documentation":"Thrown as UnresolvedForwardReference during deserialization when an @JsonIdentityInfo object-id reference cannot be matched to a previously-seen object. The id was read, but no object with that id has been registered, so Jackson cannot resolve the pointer.","triggerScenarios":"JSON using @JsonIdentityInfo where an object references an id that never appears, appears after the reference in a non-bufferable stream, or where ids are duplicated/inconsistent. Common with bidirectional JPA entity graphs serialized with identity info.","commonSituations":"Cyclic JPA entity graphs whose back-reference points to an id that was elided or never serialized; hand-edited/partial JSON snapshots missing an object; id-generator mismatch between serialization and deserialization; streaming reads that don't buffer the whole document.","solutions":["Ensure every referenced id is present in the payload and (for streaming) that object definitions appear before references, or deserialize the whole document at once so Jackson can buffer forward references.","For JPA cycles, break the cycle at serialization time (@JsonIgnore on one side) or map to flat DTOs.","Register a DeserializationProblemHandler (handleMissingId) to tolerate missing ids, or use ObjectReader.withHandler.","Catch UnresolvedForwardReference at the boundary and report which id failed."],"exampleFix":"// before: deserialization throws UnresolvedForwardReference on a missing @id\nGraph g = mapper.readValue(json, Graph.class);\n// after: tolerate unresolved ids via a problem handler\nObjectReader r = mapper.readerFor(Graph.class)\n    .withHandler(new DeserializationProblemHandler() {\n        @Override public Object handleMissingId(DeserializationContext ctxt, Object referenced) {\n            return null; // skip the dangling reference\n        }\n    });\nGraph g = r.readValue(json);","handlingStrategy":"try-catch","validationCode":"// Pre-validate that every object-id reference has a matching definition in the payload\nSet<Object> defined = collectDefinedIds(jsonNode);     // objects carrying @id\nSet<Object> referenced = collectReferencedIds(jsonNode); // pointers to those ids\nif (!defined.containsAll(referenced)) {\n    throw new IllegalArgumentException(\"JSON references undefined object ids: \"\n        + Sets.difference(referenced, defined));\n}","typeGuard":null,"tryCatchPattern":"try {\n    return mapper.readValue(json, Graph.class);\n} catch (UnresolvedForwardReference e) {\n    log.warn(\"Unresolved object id while deserializing; payload may be incomplete\", e);\n    throw new DomainException(\"Referenced entity not found in payload\", e);\n}","preventionTips":["Deserialize the whole document at once so Jackson can buffer forward references.","For JPA cycles, exclude one side with @JsonIgnore or map to flat DTOs.","Validate id completeness in tests with representative payloads.","Register a DeserializationProblemHandler.handleMissingId to tolerate missing ids where appropriate."],"tags":["object-id","forward-reference","deserialization","jsonidentityinfo"],"analyzedSha":"a50c7d2a1d57234ac4adf70dbd88ac90db6436e4","analyzedAt":"2026-08-06T20:31:51.404Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}