Skip to content

bug: Name of protocol sync classes rendered incorrectly #380

@ogenstad

Description

@ogenstad

Component

Python SDK

Infrahub SDK version

v1.11.1

Current Behavior

When trying to use the protocols together with the sync client we run into a problem due to the names of the classes.

Expected Behavior

This should not be a problem.

Steps to Reproduce

Run this snippet:

from infrahub_sdk import InfrahubClientSync
from infrahub_sdk.protocols import BuiltinTagSync

client = InfrahubClientSync()
tags = client.all(kind=BuiltinTagSync)

The error will be:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/patrick/Code/opsmill/infrahub-sdk-python/infrahub_sdk/client.py", line 1779, in all
    return self.filters(
           ^^^^^^^^^^^^^
  File "/Users/patrick/Code/opsmill/infrahub-sdk-python/infrahub_sdk/client.py", line 1915, in filters
    schema = self.schema.get(kind=kind, branch=branch)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/patrick/Code/opsmill/infrahub-sdk-python/infrahub_sdk/schema/__init__.py", line 563, in get
    raise SchemaNotFoundError(identifier=kind_str)
infrahub_sdk.exceptions.SchemaNotFoundError: Unable to find the schema 'BuiltinTagSync'.

The problematic call comes from this method in `client.schema``

    @staticmethod
    def _get_schema_name(schema: type[SchemaType | SchemaTypeSync] | str) -> str:
        if hasattr(schema, "_is_runtime_protocol") and schema._is_runtime_protocol:  # type: ignore[union-attr]
            return schema.__name__  # type: ignore[union-attr]

        if isinstance(schema, str):
            return schema

        raise ValueError("schema must be a protocol or a string")

Additional Information

No response

Metadata

Metadata

Assignees

Labels

type/bugSomething isn't working as expectedtype/newcomersGood for newcomers

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions