Skip to content

Return None from from_id() for a non-existent id on the untyped path - #120

Merged
apdavison merged 1 commit into
HumanBrainProject:masterfrom
apdavison:issue115
Aug 22, 2026
Merged

Return None from from_id() for a non-existent id on the untyped path#120
apdavison merged 1 commit into
HumanBrainProject:masterfrom
apdavison:issue115

Conversation

@apdavison

Copy link
Copy Markdown
Member

Fixes #115.

KGObject.from_id() called on the base class, where the type isn't known up front, indexed into the result of instance_from_full_uri() without checking it. That returns None for an instance that doesn't exist or isn't accessible, so the call raised TypeError: 'NoneType' object is not subscriptable instead of returning None.

The typed path already handles this correctly in from_uri(), and from_id's own docstring states that None means the object doesn't exist or the user lacks permission. Only the untyped branch was wrong.

Tests in test/test_base.py cover both the None result and the success path. Both run offline against the mock client.

@apdavison apdavison added this to the 0.15 milestone Aug 22, 2026
@apdavison apdavison added the bug Something isn't working label Aug 22, 2026
@apdavison
apdavison merged commit 72b5bce into HumanBrainProject:master Aug 22, 2026
7 checks passed
@apdavison
apdavison deleted the issue115 branch August 22, 2026 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

KGObject.from_id() raises TypeError instead of returning None for a non-existent id (untyped path)

1 participant