Repository navigation
Conversation
…xpects parse_filter_args() kept every value as a string, so boolean filters such as <relationship>__isnull=true were sent as the GraphQL string "true" and rejected by the server. Values for __isnull, __is_visible and __is_protected filters now become booleans, and <attribute>__value filters on Boolean or Number attributes become booleans or integers, based on the node schema. Other values stay strings. Fixes #1417
Deploying infrahub-sdk-python with
|
| Latest commit: |
ce42823
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://a363f349.infrahub-sdk-python.pages.dev |
| Branch Preview URL: | https://ai-bug-pipeline-1417-filter.infrahub-sdk-python.pages.dev |
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## stable #1418 +/- ##
==========================================
+ Coverage 85.06% 85.11% +0.04%
==========================================
Files 148 148
Lines 13303 13312 +9
Branches 1960 1958 -2
==========================================
+ Hits 11316 11330 +14
+ Misses 1422 1418 -4
+ Partials 565 564 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 2 files with indirect coverage changes 🚀 New features to boost your workflow:
|
lancamat1
marked this pull request as ready for review
October 14, 2026 12:30
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
infrahubctl object get --filtersends every filter value to Infrahub as a string. Filters whose GraphQL argument is not a string fail, for example--filter interfaces__isnull=truereturnsBoolean cannot represent a non boolean value: "true". The same filter works throughclient.filters(..., interfaces__isnull=True).The goal is that
--filtersends boolean and integer values with the type the filter expects, so these filters work from the CLI the same way they work from the SDK.Non-goals:
<relationship>__<peer_attribute>__value) are still sent as strings, typing them would need the peer schema as well__valueslist filters,--filterhas no list syntax todaypartial_match, which is aboolkeyword ofclient.filters()and still receives a string when passed through--filterCloses #1417
What changed
__isnull,__is_visibleand__is_protectedfilters are sent as booleans (true,false,yes,no, case insensitive)<attribute>__valuefilters on Boolean or Checkbox attributes are sent as booleans, and on Number or NumberPool attributes as integers, based on the node schemaobject getalready loadsname__value=123on a Text attribute is still sent as"123"interfaces__isnull=maybe) now fails in the CLI with a message naming the filter and the expected type, instead of a 500 from the serverparse_filter_args()gets an optionalschemaargument, so existing callers keep working. Thetrue/falsekeyword map is now shared with--setparsing, the--setbehaviour does not change.How to review
The change is in
infrahub_sdk/ctl/parsers.py, the one-line call site change is ininfrahub_sdk/ctl/object/get.py.The part I would like a second opinion on is the decision to type values from the filter suffix and the attribute kind, instead of running
_coerce_value()on every value like--setdoes. Coercing everything would turnname__value=123into an integer and break String filters the opposite way.How to test
test_get_list_mode_isnull_filter_passes_booleanreproduces bug: infrahubctl object get --filter sends boolean values as strings #1417, it was committed first and fails without the fixTestParseFilterArgscases cover the boolean suffixes, Boolean and Number attribute values, Text and peer filter values that must stay strings, and invalid valuesLocally
invoke format,invoke lint-codeandinvoke docs-validatepass. I have not run the fixed command against a live Infrahub instance, the tests check the values passed toclient.filters().Impact & rollout
--filtervalue that cannot be converted for a boolean or integer filter now fails in the CLI instead of on the server.Checklist
uv run towncrier create ...)--filterhelp text and the generated CLI docs do not changeSummary by cubic
Fixes
infrahubctl object get --filtersending boolean and integer filter values as strings, which made filters likeinterfaces__isnull=truefail with a GraphQL type error. Values for__isnull,__is_visible,__is_protected, and__valuefilters on Boolean/Number attributes are now converted to the expected type based on the suffix and the node schema; all other values stay stringsesth.Backward compatibility
Written for commit ce42823. Summary will update on new commits.