Visitar URL original
bug: infrahubctl object get --filter sends boolean values as strings · Issue #1417 · opsmill/infrahub-sdk-python · GitHub
Skip to content

bug: infrahubctl object get --filter sends boolean values as strings #1417

Open

Description

@lancamat1

Component

infrahubctl

Infrahub SDK version

1.23.2 (the code below is the same on stable at commit 5ba81c0)

Current Behavior

infrahubctl object get --filter sends every filter value to Infrahub as a string. A filter whose GraphQL argument is Boolean, such as a relationship __isnull filter, fails because the value true reaches the server as the string "true":

{'message': 'Boolean cannot represent a non boolean value: "true"', 'locations': [{'line': 3, 'column': 36}], 'extensions': {'code': 'UNDEFINED_ERROR', 'http_status': 500, 'data': {}}}

The same filter works when passed as a Python boolean to client.filters(..., <relationship>__isnull=True).

Expected Behavior

infrahubctl object get --filter <relationship>__isnull=true returns the nodes that have no peer on that relationship, the same result as client.filters() with <relationship>__isnull=True.

Steps to Reproduce

  1. Load a schema with a node kind that has an optional relationship, for example InfraDevice with a cardinality-many relationship interfaces.
  2. Run:
    infrahubctl object get InfraDevice --filter interfaces__isnull=true --output csv --branch main
    
  3. The command fails with Boolean cannot represent a non boolean value: "true".

Additional Information

  • parse_filter_args() stores each --filter value as the raw string. parse_set_args() in the same file converts true, false and numbers for --set, but --filter does not.
  • object get passes the parsed values unchanged to client.filters(), which writes a Python string into the query as a quoted GraphQL string.
  • The unit tests for parse_filter_args() in tests/unit/ctl/test_parsers.py cover only string values.
  • The original report came from a production deployment, with the error above. The steps above are based on reading the code and have not been run against a test instance. Filters on Boolean or integer attributes (for example <boolean attribute>__value=true) probably fail in the same way, but this has not been tested.
  • Related: bug: isnull filters are missing in the schema endpoint #30 (isnull filters missing from the schema endpoint, closed).

Assisted-by: opsmill-dev-creating-issues 0.3.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions