EDGE-278 Log Forbidden message is unclear#533
Merged
Conversation
- Add handling for 403 (Forbidden) errors in CheckinWorker and Runtime - Clarify 401 error message with Unauthorized label and fix grammar - Parametrize test_on_fatal_hook_is_called to verify both 401 and 403 paths
There was a problem hiding this comment.
Code Review
This pull request improves error handling for CDF API requests by adding explicit support for 403 (Forbidden) errors and refining the log messages for 401 (Unauthorized) errors in both checkin_worker.py and runtime.py. Additionally, the test suite was updated to include parametrized tests for both status codes. I have no feedback to provide.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #533 +/- ##
==========================================
- Coverage 81.97% 81.90% -0.08%
==========================================
Files 43 43
Lines 4217 4222 +5
==========================================
+ Hits 3457 3458 +1
- Misses 760 764 +4
🚀 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.
Background
While starting the file extractor main branch, if the application (client ID) doesnt have required permission (case observed) for the cognite API
/api/v1/projects/{self._cognite_client.config.project}/odin/checkin, raises aCogntieAPIErrorwith status code403and error message"Forbidden"and the log shows only “Forbidden”. The log could be improved.Summary
This PR addresses error handling for authentication and authorization failures from CDF:
Changes
checkin_worker.py&runtime.pyelif e.code == 403:block with Forbidden error messagetest_checkin_worker.pytest_on_fatal_hook_is_calledwith@pytest.mark.parametrizedecoratoridsfor test output clarityTest Plan
test_on_fatal_hook_is_called[401-Unauthorized]— verifies fatal hook fires on 401test_on_fatal_hook_is_called[403-Forbidden]— verifies fatal hook fires on 403