{"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/87876ca5c0569b4933aec2d30d6225e4b9ba3a43/src/main/java/tools/jackson/databind/deser/AbstractDeserializer.java#L297-L322","documentation":"Thrown as UnresolvedForwardReference by AbstractDeserializer._deserializeFromObjectId when a referenced Object Id (from @JsonIdentityInfo) cannot be resolved by the time it is needed, meaning the defining object never appeared (or appeared later than the reference). This indicates a data/integrity problem: the JSON contains an @id reference with no matching @id definition earlier in the stream.","triggerScenarios":"Deserializing JSON that uses @JsonIdentityInfo where an object references an id that does not exist in the stream, or that appears after the reference (forward reference that never resolves before the parser reaches the end of the relevant scope).","commonSituations":"Bi-directional relationships serialized with ids where one side was dropped; partial/truncated JSON payloads; reordered fields where the referenced entity is in a sibling not yet parsed; integrating with a store that emits forward references.","solutions":["Ensure the JSON defines every object (with its @id) before any reference to it; reorder the payload or pre-seed the referenced objects.","Validate payload integrity upstream before handing it to Jackson.","If references can legitimately be unknown, register a DeserializationProblemHandler (or use readValueAs(Iterator)/ObjectMapper.readerForUpdating) to handle or skip unknown ids.","Verify @JsonIdentityInfo is configured consistently on both serialization and deserialization sides (generator, resolver, scope)."],"exampleFix":"// before: reference 2 appears, but object with @id=2 is missing/after\n[{\"@id\":1,\"name\":\"a\",\"ref\":2}]\n\n// after: define id 2 first (or include it in the stream)\n[{\"@id\":2,\"name\":\"b\"},{\"@id\":1,\"name\":\"a\",\"ref\":2}]","handlingStrategy":"try-catch","validationCode":"// Before deserializing, validate that every referenced @id has a matching definition in the payload (application-level check).\nSet<Object> defined = collectDefinedIds(json);\nSet<Object> referenced = collectReferencedIds(json);\nif (!defined.containsAll(referenced)) throw new IllegalStateException(\"Unresolved ids: \" + difference);","typeGuard":null,"tryCatchPattern":"try {\n    mapper.readValue(json, Node.class);\n} catch (UnresolvedForwardReference e) {\n    // log the missing id (e.getRoid().hasId()) and handle/report\n}","preventionTips":["Define objects before referencing them in @JsonIdentityInfo payloads.","Keep @JsonIdentityInfo config identical on both serialization and deserialization sides.","Register a DeserializationProblemHandler to tolerate missing ids when appropriate.","Validate payload integrity upstream for untrusted sources."],"tags":["jackson","deserialization","objectid","forward-reference","data-integrity"],"backgroundTag":null,"analyzedSha":"87876ca5c0569b4933aec2d30d6225e4b9ba3a43","analyzedAt":"2026-08-11T12:55:24.033Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}