Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Having a relationship named pool breaks GraphQL API #4807

Open
gmazoyer opened this issue Oct 31, 2024 · 0 comments
Open

bug: Having a relationship named pool breaks GraphQL API #4807

gmazoyer opened this issue Oct 31, 2024 · 0 comments
Labels
priority/2 This issue stalls work on the project or its dependents, it's a blocker for a release type/bug Something isn't working as expected

Comments

@gmazoyer
Copy link
Contributor

Component

API Server / GraphQL

Infrahub version

1.0.0

Current Behavior

Using the name pool for a relationship in a node schema will cause a failure when executing a GraphQL query.

Expected Behavior

There should not be any issues.

Steps to Reproduce

  1. Start Infrahub and load demo schema and data
  2. Add the below schema extension
  3. Try to fetch sites nodes and observe the failure
---
version: "1.0"
extensions:
  nodes:
    - kind: LocationSite
      relationships:
        - name: pool
          peer: CoreIPAddressPool
          cardinality: one

Additional Information

The failure is raised because of a dynamic lookup of a function based on its name, in this case the name will be process_pool.

{"event": "Unhandled exception occurred in resolvers", "worker": "2416f484-99ed-41ae-8488-7704cd4b3da1", "app": "infrahub.api", "request_id": "f18f91343e0f4f38ac21753a27067c61", "timestamp": "2024-10-31T11:31:07.944845Z", "logger": "infrahub.graphql", "level": "critical", "exception": "Traceback (most recent call last):\n  File \"/Users/gmazoyer/Library/Caches/pypoetry/virtualenvs/infrahub-server-gZy67cgI-py3.12/lib/python3.12/site-packages/graphql/execution/execute.py\", line 530, in await_result\n    return_type, field_nodes, info, path, await result\n                                          ^^^^^^^^^^^^\n  File \"/Users/gmazoyer/Development/infrahub/backend/infrahub/graphql/resolver.py\", line 163, in default_paginated_list_resolver\n    objs = await NodeManager.query(\n           ^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/Users/gmazoyer/Development/infrahub/backend/infrahub/core/manager.py\", line 244, in query\n    response = await cls.get_many(\n               ^^^^^^^^^^^^^^^^^^^\n  File \"/Users/gmazoyer/Development/infrahub/backend/infrahub/core/manager.py\", line 1209, in get_many\n    await item.load(**new_node_data_with_profile_overrides, db=db)\n  File \"/Users/gmazoyer/Development/infrahub/backend/infrahub/core/node/__init__.py\", line 437, in load\n    await self._process_fields(db=db, fields=kwargs)\n  File \"/Users/gmazoyer/Development/infrahub/backend/infrahub/core/node/__init__.py\", line 351, in _process_fields\n    await getattr(self, f\"process_{name}\")(db=db)\n          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nTypeError: Node.process_pool() missing 2 required positional arguments: 'attribute' and 'errors'"}

The functions is then called with the bad number of parameters.

@gmazoyer gmazoyer added the type/bug Something isn't working as expected label Oct 31, 2024
@gmazoyer gmazoyer added this to the Infrahub - 1.0.1 milestone Oct 31, 2024
@gmazoyer gmazoyer changed the title bug: Having an relationship named pool breaks GraphQL API bug: Having a relationship named pool breaks GraphQL API Oct 31, 2024
@exalate-issue-sync exalate-issue-sync bot added the priority/2 This issue stalls work on the project or its dependents, it's a blocker for a release label Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority/2 This issue stalls work on the project or its dependents, it's a blocker for a release type/bug Something isn't working as expected
Projects
None yet
Development

No branches or pull requests

1 participant