From d8f914a8ed41b4578c1968157db26d344570e48c Mon Sep 17 00:00:00 2001 From: Aaron McCarty Date: Wed, 21 Jan 2026 16:10:51 -0800 Subject: [PATCH 1/4] use CoreNodeBase in get_schema_name --- infrahub_sdk/store.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/infrahub_sdk/store.py b/infrahub_sdk/store.py index 6420495b..aaf72b45 100644 --- a/infrahub_sdk/store.py +++ b/infrahub_sdk/store.py @@ -1,8 +1,11 @@ from __future__ import annotations +import inspect import warnings from typing import TYPE_CHECKING, Literal, overload +from infrahub_sdk.protocols_base import CoreNodeBase + from .exceptions import NodeInvalidError, NodeNotFoundError from .node.parsers import parse_human_friendly_id @@ -16,8 +19,15 @@ def get_schema_name(schema: type[SchemaType | SchemaTypeSync] | str | None = Non if isinstance(schema, str): return schema - if hasattr(schema, "_is_runtime_protocol") and schema._is_runtime_protocol: # type: ignore[union-attr] - return schema.__name__ # type: ignore[union-attr] + if schema is None: + return None + + if issubclass(schema, CoreNodeBase): + if inspect.iscoroutinefunction(schema.save): + return schema.__name__ + if schema.__name__[-4:] == "Sync": + return schema.__name__[:-4] + return schema.__name__ return None @@ -101,6 +111,8 @@ def get( message=f"Found a node of a different kind instead of {kind} for key {key!r} in the store ({self.branch_name})", ) + breakpoint() + raise NodeNotFoundError( identifier={"key": [key] if isinstance(key, str) else key}, message=f"Unable to find the node {key!r} in the store ({self.branch_name})", From 8b29af02dc4242b1fe51cdcd41809e8584ccb0b0 Mon Sep 17 00:00:00 2001 From: Aaron McCarty Date: Wed, 21 Jan 2026 16:14:22 -0800 Subject: [PATCH 2/4] remove breakpoint --- infrahub_sdk/store.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/infrahub_sdk/store.py b/infrahub_sdk/store.py index aaf72b45..e8406b10 100644 --- a/infrahub_sdk/store.py +++ b/infrahub_sdk/store.py @@ -111,8 +111,6 @@ def get( message=f"Found a node of a different kind instead of {kind} for key {key!r} in the store ({self.branch_name})", ) - breakpoint() - raise NodeNotFoundError( identifier={"key": [key] if isinstance(key, str) else key}, message=f"Unable to find the node {key!r} in the store ({self.branch_name})", From abdd5191d46b8d26886ebc3aeb394a781877cb06 Mon Sep 17 00:00:00 2001 From: Sola Babatunde Date: Thu, 22 Jan 2026 08:58:05 +0100 Subject: [PATCH 3/4] add test for store get_schema_name --- tests/unit/sdk/test_store.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/unit/sdk/test_store.py b/tests/unit/sdk/test_store.py index 83644aae..b049616a 100644 --- a/tests/unit/sdk/test_store.py +++ b/tests/unit/sdk/test_store.py @@ -6,7 +6,8 @@ from infrahub_sdk.exceptions import NodeInvalidError, NodeNotFoundError from infrahub_sdk.node import InfrahubNode, InfrahubNodeSync -from infrahub_sdk.store import NodeStore, NodeStoreSync +from infrahub_sdk.protocols import BuiltinIPPrefix +from infrahub_sdk.store import NodeStore, NodeStoreSync, get_schema_name if TYPE_CHECKING: from infrahub_sdk.schema import NodeSchemaAPI @@ -157,3 +158,7 @@ def test_node_store_get_with_hfid( store.get(kind="BuiltinLocation", key="anotherkey") with pytest.raises(NodeNotFoundError): store.get(key="anotherkey") + + +def test_store_get_schema_name() -> None: + assert get_schema_name(schema=BuiltinIPPrefix) == BuiltinIPPrefix.__name__ From 42ac2d4fcd96e1d78be4604a72002c3419edbfc0 Mon Sep 17 00:00:00 2001 From: Sola Babatunde Date: Thu, 22 Jan 2026 09:25:25 +0100 Subject: [PATCH 4/4] update test --- tests/unit/sdk/test_store.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/unit/sdk/test_store.py b/tests/unit/sdk/test_store.py index b049616a..eaeab57c 100644 --- a/tests/unit/sdk/test_store.py +++ b/tests/unit/sdk/test_store.py @@ -6,7 +6,7 @@ from infrahub_sdk.exceptions import NodeInvalidError, NodeNotFoundError from infrahub_sdk.node import InfrahubNode, InfrahubNodeSync -from infrahub_sdk.protocols import BuiltinIPPrefix +from infrahub_sdk.protocols import BuiltinIPAddressSync, BuiltinIPPrefix from infrahub_sdk.store import NodeStore, NodeStoreSync, get_schema_name if TYPE_CHECKING: @@ -162,3 +162,4 @@ def test_node_store_get_with_hfid( def test_store_get_schema_name() -> None: assert get_schema_name(schema=BuiltinIPPrefix) == BuiltinIPPrefix.__name__ + assert get_schema_name(schema=BuiltinIPAddressSync) == BuiltinIPAddressSync.__name__[:-4]