Skip to content

bug: Client does not support from_pool on number fieldsΒ #497

@minitriga

Description

@minitriga

Component

SDK

This issue contains output that could show another bug that is captured in #339 which is in regards to the vlan_id being used in the HFID. This issue is to only focus on the generated graphql.

Infrahub SDK version

1.13.5

Current Behavior

When using the SDK I would like to specify a number pool identifier to be idempotent when assigning number pools.

mutation {
    InfraVLANUpsert(
        data: {
            name: {
                value: "Example VLAN"
            }
            role: {
                value: "user"
            }
            vlan_id: {
                value: {
                    from_pool: {
                        id: "185b9728-1b76-dda7-d13d-106529b1bcd9"
                        identifier: "test"
                    }
                }
            }
            status: {
                value: "active"
            }
            hfid: [
                "Example VLAN",
                "{'from_pool': {'id': '185b9728-1b76-dda7-d13d-106529b1bcd9', 'identifier': 'test'}}",
            ]
        }
    ){
        ok
        object {
            id
        }
    }
}

Error:

  File "/private/tmp/test/.venv/lib/python3.11/site-packages/infrahub_sdk/client.py", line 1697, in execute_graphql
    raise GraphQLError(errors=response["errors"], query=query, variables=variables)
infrahub_sdk.exceptions.GraphQLError: An error occurred while executing the GraphQL Query 
mutation {
    InfraVLANUpsert(
        data: {
            name: {
                value: "Example VLAN"
            }
            role: {
                value: "user"
            }
            vlan_id: {
                value: {
                    from_pool: {
                        id: "185b9728-1b76-dda7-d13d-106529b1bcd9"
                        identifier: "test"
                    }
                }
            }
            status: {
                value: "active"
            }
            hfid: [
                "Example VLAN",
                "{'from_pool': {'id': '185b9728-1b76-dda7-d13d-106529b1bcd9', 'identifier': 'test'}}",
            ]
        }
    ){
        ok
        object {
            id
        }
    }
}
, [{'message': 'Expected value of type \'BigInt\', found {from_pool: {id: "185b9728-1b76-dda7-d13d-106529b1bcd9", identifier: "test"}}.', 'locations': [{'line': 12, 'column': 24}]}]

Expected Behavior

I would expect the key vlan_id to not have value and from_pool be directly under vlan_id. However this still leaves the open issue of the backend not supporting identifiers for number pool assignments. opsmill/infrahub#7036

I'm aware there is another bug present in this output this is captured here: #339 however this issue is to solely focus on the incorrect graphql generated

Steps to Reproduce

  1. Login to demo.infrahub.app
  2. Create a number pool for InfraVlan and the vlan_id field
  3. Create a new vlan using the pool
  4. Run the following python script
from infrahub_sdk import InfrahubClientSync

client = InfrahubClientSync()
pool = client.get(kind="CoreNumberPool", id="185b9728-1b76-dda7-d13d-106529b1bcd9")
vlan = {
    "kind": "InfraVLAN",
    "name": "Example VLAN",
    "vlan_id": {"from_pool": {"id": pool.id, "identifier": "test"}},
    "role": "user",
    "status": "active"
}
client.config.echo_graphql_queries = True
vlan = client.create(**vlan)
vlan.save(allow_upsert=True)
client.config.echo_graphql_queries = False

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/2This issue stalls work on the project or its dependents, it's a blocker for a releasetype/bugSomething isn't working as expected

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions