-
Notifications
You must be signed in to change notification settings - Fork 12
fix: add labels to NodeNotFoundError for clearer messaging #1030
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
Open
DharmaBytesX
wants to merge
2
commits into
opsmill:develop
Choose a base branch
from
DharmaBytesX:fix/5514-better-node-not-found-error
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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.
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 don't think we should have if-statements within the
__str__()method of classes in general. I think the problem here is really that the parameters to the__init__()method are optional instead of being required. We should probably look at the places where we raise this error and check if we are always sending in all fields (or if we have enough information to do so) and then update the init method to require there parameters.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.
Thanks for the review. I've reworked the change along the lines you suggested:
branch_name,node_typeandidentifierare now required keyword-only parameters ofNodeNotFoundError.__init__, and__str__no longer has any conditional logic.I audited the call sites and updated them to always pass the three fields:
infrahub_sdk/client.pywas already passing all three.infrahub_sdk/ctl/object/utils.pynow resolves the branch toclient.default_branchwhen the caller did not provide one.infrahub_sdk/file_handler.py:handle_responseandhandle_error_responsenow takebranchandnode_id, plumbed fromFileHandler.download/_stream_to_filein both the async and sync paths.infrahub_sdk/store.py: passesself.branch_name, and falls back to"unknown"only on the internal lookup paths where the caller genuinely never specified a kind.Also added
tests/unit/sdk/test_exceptions.pycovering the new contract (keyword-only, all three required, rendered format).