-
Notifications
You must be signed in to change notification settings - Fork 6
Fix: exclude uninitialized hierarchy relationships from mutation data #810
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
Fix: exclude uninitialized hierarchy relationships from mutation data #810
Conversation
WalkthroughAdds a guard in input-data generation to skip hierarchical relationships (parent, children, ancestors, descendants) unless those relationships have been explicitly initialized, preventing uninitialized hierarchical relations from being included in mutation payloads. The change is confined to the relationship-processing loop in node input generation. Tests were added to verify that uninitialized hierarchical relations are excluded and explicitly initialized ones are included, covering both standard and sync client paths. 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. No actionable comments were generated in the recent review. 🎉 Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
When saving a hierarchical node with allow_upsert=True, the SDK was including `parent: null` in the GraphQL mutation for nodes without a parent (e.g. top-level fabric nodes). Infrahub rejects this because hierarchy relationships are not assignable via mutations. Skip hierarchy relationships in _generate_input_data() unless they were explicitly initialized with data. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ef3aab1 to
40eb72c
Compare
Deploying infrahub-sdk-python with
|
| Latest commit: |
40eb72c
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://52c4f66e.infrahub-sdk-python.pages.dev |
| Branch Preview URL: | https://fix-skip-hierarchy-relations-y0nh.infrahub-sdk-python.pages.dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@tests/unit/sdk/test_hierarchical_nodes.py`:
- Around line 50-54: Replace the tuple membership test with a set literal to
satisfy PLR6201: in the loop over schema_api.relationships where you check
rel.name in ("parent", "children"), change that membership test to use a set
literal {"parent", "children"} so the condition uses a set for faster membership
checks (refer to the loop and the rel.name check).
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## stable #810 +/- ##
==========================================
- Coverage 80.37% 80.34% -0.03%
==========================================
Files 115 115
Lines 9873 9875 +2
Branches 1504 1505 +1
==========================================
- Hits 7935 7934 -1
- Misses 1416 1420 +4
+ Partials 522 521 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
ajtmccarty
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not the most familiar with all the inner workings of the SDK, but I think this looks reasonable
I'd give it a day for anyone else on @opsmill/backend to review before merging
|
Closing this and creating a better issue to track this as there is a larger problem here: #821 |
When saving a hierarchical node with allow_upsert=True, the SDK was including
parent: nullin the GraphQL mutation for nodes without a parent (e.g. top-level fabric nodes). Infrahub rejects this because hierarchy relationships are not assignable via mutations.Skip hierarchy relationships in _generate_input_data() unless they were explicitly initialized with data.
Summary by CodeRabbit
Bug Fixes
Tests