{"record":{"id":"095e81a606d0383a","repo":"run-llama/llama_index","slug":"fnnodemapping-does-not-support-obj-node-mapping","errorCode":null,"errorMessage":"FnNodeMapping does not support obj_node_mapping","messagePattern":"FnNodeMapping does not support obj_node_mapping","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/objects/fn_node_mapping.py","lineNumber":50,"sourceCode":"    ) -> \"BaseObjectNodeMapping\":\n        \"\"\"Initialize node mapping.\"\"\"\n        return cls(from_node_fn, to_node_fn)\n\n    def _add_object(self, obj: Any) -> None:\n        \"\"\"Add object. NOTE: unused.\"\"\"\n\n    def to_node(self, obj: Any) -> BaseNode:\n        \"\"\"To node.\"\"\"\n        return self._to_node_fn(obj)\n\n    def _from_node(self, node: BaseNode) -> Any:\n        \"\"\"From node.\"\"\"\n        return self._from_node_fn(node)\n\n    @property\n    def obj_node_mapping(self) -> Dict[int, Any]:\n        \"\"\"The mapping data structure between node and object.\"\"\"\n        raise NotImplementedError(\"FnNodeMapping does not support obj_node_mapping\")\n\n    def persist(\n        self, persist_dir: str = ..., obj_node_mapping_fname: str = ...\n    ) -> None:\n        \"\"\"Persist objs.\"\"\"\n        raise NotImplementedError(\"FnNodeMapping does not support persist method.\")\n\n    @classmethod\n    def from_persist_dir(\n        cls,\n        persist_dir: str = DEFAULT_PERSIST_DIR,\n        obj_node_mapping_fname: str = DEFAULT_PERSIST_FNAME,\n    ) -> \"FnNodeMapping\":\n        raise NotImplementedError(\"FnNodeMapping does not support persist method.\")\n","sourceCodeStart":32,"sourceCodeEnd":65,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/objects/fn_node_mapping.py#L32-L65","documentation":"FnObjectNodeMapping maps objects to nodes purely through user-supplied to/from-node functions and keeps no in-memory dict. Therefore the obj_node_mapping property is declared but intentionally unimplemented and raises NotImplementedError. There is no stored mapping to expose by design.","triggerScenarios":"Accessing fn_mapping.obj_node_mapping on an FnObjectNodeMapping instance, or any code path that iterates/inspects mappings generically (e.g. len(mapping), list(mapping.obj_node_mapping.items())) after building an ObjectIndex with FnObjectNodeMapping.","commonSituations":"Generic tooling written against BaseObjectNodeMapping that assumes every mapping exposes obj_node_mapping; interactive inspection of an ObjectIndex built over functions; reusing code that worked with SimpleObjectNodeMapping.","solutions":["Track objects yourself in a dict when using FnObjectNodeMapping and use that instead of obj_node_mapping","Switch to SimpleObjectNodeMapping if you need an inspectable in-memory mapping and your objects are pickleable","Guard generic code with hasattr/try-except NotImplementedError before touching obj_node_mapping"],"exampleFix":"# before\nnode_mapping = FnObjectNodeMapping(to_node_fn, from_node_fn)\nitems = node_mapping.obj_node_mapping  # NotImplementedError\n\n# after\nnode_mapping = SimpleObjectNodeMapping.from_objects(objs)  # pickleable objs\nitems = node_mapping.obj_node_mapping","handlingStrategy":"type-guard","validationCode":"from llama_index.core.objects import FnObjectNodeMapping\nif isinstance(node_mapping, FnObjectNodeMapping):\n    raise TypeError(\"FnObjectNodeMapping exposes no obj_node_mapping; keep your own object registry\")","typeGuard":"def supports_obj_node_mapping(mapping) -> bool:\n    from llama_index.core.objects import SimpleObjectNodeMapping\n    return isinstance(mapping, SimpleObjectNodeMapping)","tryCatchPattern":"try:\n    items = mapping.obj_node_mapping\nexcept NotImplementedError:\n    items = {}  # Fn-based mapping: nothing to enumerate; use your own registry","preventionTips":["Track objects in your own dict when using FnObjectNodeMapping","Write generic mapping code against SimpleObjectNodeMapping or guard with isinstance"],"tags":["object-index","node-mapping","not-implemented","api-limitation"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}