fix(ctl): handle extensions paths in display_schema_load_errors (#1007)#1008
Open
fix(ctl): handle extensions paths in display_schema_load_errors (#1007)#1008
Conversation
Merge stable into develop
Merge stable into develop
Merge stable into develop
Merge stable into develop
Merge stable into develop
Merge stable into develop
Merge stable into develop
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## stable #1008 +/- ##
==========================================
+ Coverage 81.41% 81.42% +0.01%
==========================================
Files 134 134
Lines 11347 11365 +18
Branches 1703 1707 +4
==========================================
+ Hits 9238 9254 +16
- Misses 1566 1568 +2
Partials 543 543
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Contributor
|
Not a review but just highlighting that we also want a towncrier newsfragment under /changelog so that we include what was fixed in the release notes. Also in general when we're fixing bugs it's fine to target the |
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Deploying infrahub-sdk-python with
|
| Latest commit: |
90c534d
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://f1423771.infrahub-sdk-python.pages.dev |
| Branch Preview URL: | https://ic-fix-display-schema-load-e.infrahub-sdk-python.pages.dev |
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 schema loadcrashes with an unhandledValueErrorwhen theserver rejects a schema that uses the
extensions:block. The traceback replaces thehuman-readable rejection message, so users have no idea what the server
actually rejected.
Goal: Render extensions-block rejections in the same one-line format as
top-level rejections.
Non-goals: No new error categories, no changes to
infrahubctl schema checkor to the server's rejection format, no broader refactor of the CLIschema commands.
Closes #1007
What changed
Behavioral changes
extensions:block now render asNode: <kind> (extensions/<container>) | <field> (<input>) | <msg> (<type>)instead of crashing with
ValueError: invalid literal for int() with base 10.loc_pathshapes (non-int schema index, unrecognisedcontainer) are skipped silently instead of crashing the renderer.
preserved by the existing tests.
Implementation notes
display_schema_load_errorsnow branches onloc_path[3] == "extensions",computes
container / node_index / tailonce, and dispatches onlen(tail)instead of
len(loc_path)so the offset shift doesn't have to be repeated._render_schema_errorto keep the mainloop within the project's branch-count limits.
valid_error_pathnow whitelistsloc_path[3] in {nodes, generics, extensions}and requiresloc_path[2](and the node-index slot) to beint.get_nodegainedcontainerandis_extensionkwargs (defaults match theold behaviour) and uses
payload.get(...)so a schema file with onlyextensions:no longer raisesKeyError.What stayed the same
display_schema_load_errorsunchanged.get_nodesignature is backward-compatible (new params have defaults).How to review
infrahub_sdk/ctl/schema.py— start with_render_schema_error, thenvalid_error_path, thenget_node.tests/unit/sdk/test_schema.py— three new tests cover top-level extensionserrors, nested-attribute extensions errors, and the malformed-path filter.
and still pass — that's the regression guard for the format-stability claim
above.
The
valid_error_pathwhitelist is the area I'd most want a second opinionon: if the server later adds a new top-level container, errors against it
will now be silently skipped instead of bubbling up. The trade-off is
intentional for a CLI rendering helper, but worth flagging.
How to test
Impact & rollout
errors is unchanged.
get_nodegained two optional kwargs with defaults.schema load.Checklist
uv run towncrier create +fix-schema-load-extensions.fixed.md)