IHS-119: Fix upsert not working for numberpool and attribute in hfid#1014
Open
solababs wants to merge 2 commits into
Open
IHS-119: Fix upsert not working for numberpool and attribute in hfid#1014solababs wants to merge 2 commits into
solababs wants to merge 2 commits into
Conversation
Deploying infrahub-sdk-python with
|
| Latest commit: |
98047b9
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://1644a246.infrahub-sdk-python.pages.dev |
| Branch Preview URL: | https://sb-12052026-fix-upsert-numbe.infrahub-sdk-python.pages.dev |
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## stable #1014 +/- ##
==========================================
+ Coverage 81.56% 81.59% +0.02%
==========================================
Files 134 134
Lines 11442 11460 +18
Branches 1730 1736 +6
==========================================
+ Hits 9333 9351 +18
- Misses 1564 1565 +1
+ Partials 545 544 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
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
node.save(allow_upsert=True)on a node whose human-friendly identifier (HFID) contains aCoreNumberPool-sourced attribute crashes with"invalid literal for int() with base 10: 'VLAN ID Pool - Test'". The backend upsert resolver tries to use the unresolved pool reference as an HFID component, but the integer value is not assigned until after the server creates the node — making the upsert semantically impossible.This PR adds a client-side guard that detects the pattern and raises a descriptive
ValidationErrorbefore any network call is made.Closes #339
How to test
Checklist
python_sdk/changelog/339.fixed.md)docs/docs/python-sdk/guides/resource-manager.mdx)Summary by cubic
Prevented crashes when calling
save(allow_upsert=True)on nodes whose HFID includes aCoreNumberPool-sourced attribute by adding a client-side check that raises a clearValidationError. Addresses IHS-119.InfrahubNode.save()(async and sync) to detect pool-backed HFID attributes and raiseValidationErrorbefore any request whenallow_upsert=Trueand noidis set.idis provided or when the pool-backed attribute is not part of the HFID.Written for commit 98047b9. Summary will update on new commits.