When from_id() is called on the base KGObject class (i.e. the type isn't known up front) with an id that doesn't exist in the KG, it raises TypeError: 'NoneType' object is not subscriptable instead of returning None.
In fairgraph/kgobject.py, the untyped branch of from_id() does:
data = client.instance_from_full_uri(uri, use_cache=use_cache, release_status=release_status)
type_ = data["@type"]
instance_from_full_uri() returns None for a missing/inaccessible instance, so data["@type"] fails.
The typed path (from_uri) handles this correctly with if data is None: return None, and the from_id docstring states that a return of None means the object doesn't exist or isn't accessible — so the untyped path should behave the same.
Repro:
from fairgraph import KGClient, KGObject
client = KGClient(host="core.kg.ebrains.eu")
KGObject.from_id("https://kg.ebrains.eu/api/instances/<nonexistent-uuid>", client, release_status="any")
# -> TypeError: 'NoneType' object is not subscriptable
Suggested fix: guard data is None (return None) in the untyped branch, mirroring from_uri. Seen with fairgraph 0.13.6.
When
from_id()is called on the baseKGObjectclass (i.e. the type isn't known up front) with an id that doesn't exist in the KG, it raisesTypeError: 'NoneType' object is not subscriptableinstead of returningNone.In
fairgraph/kgobject.py, the untyped branch offrom_id()does:instance_from_full_uri()returnsNonefor a missing/inaccessible instance, sodata["@type"]fails.The typed path (
from_uri) handles this correctly withif data is None: return None, and thefrom_iddocstring states that a return ofNonemeans the object doesn't exist or isn't accessible — so the untyped path should behave the same.Repro:
Suggested fix: guard
data is None(returnNone) in the untyped branch, mirroringfrom_uri. Seen with fairgraph 0.13.6.