Skip to content

Commit 0600957

Browse files
dgarrosclaude
andcommitted
fix(schema): fix kind access on write-typed schemas after read-only kind move
Retype the topological sorter's input to the read model (NodeSchemaAPI), and convert YAML-loaded write schemas to their API form in the protocols command so `kind` (a read-only computed field) resolves. Clears ty unresolved-attribute errors introduced by moving kind/hash to the read models. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 8c7b2a8 commit 0600957

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

infrahub_sdk/ctl/cli_commands.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,11 @@ def protocols(
379379
data.load_content()
380380
schema_root_data = data.content or {}
381381
schema_root = SchemaRoot(**schema_root_data)
382-
schema.update({item.kind: item for item in schema_root.nodes + schema_root.generics})
382+
# `kind` is a read-model concept, so convert the write models loaded from disk to their
383+
# API form to key them by kind consistently with the branch-fetched path below.
384+
api_items = [node.convert_api() for node in schema_root.nodes]
385+
api_items += [generic.convert_api() for generic in schema_root.generics]
386+
schema.update({item.kind: item for item in api_items})
383387

384388
else:
385389
client = initialize_client_sync()

infrahub_sdk/transfer/schema_sorter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
from .exceptions import SchemaImportError
88

99
if TYPE_CHECKING:
10-
from ..schema import NodeSchema
10+
from ..schema import NodeSchemaAPI
1111

1212

1313
class InfrahubSchemaTopologicalSorter:
1414
def get_sorted_node_schema(
1515
self,
16-
schemas: Sequence[NodeSchema],
16+
schemas: Sequence[NodeSchemaAPI],
1717
required_relationships_only: bool = True,
1818
include: list[str] | None = None,
1919
) -> list[set[str]]:

0 commit comments

Comments
 (0)