Conversation
get_raw now honors self.retries by wrapping the session.get call in a retry loop that retries transient failures (aiohttp.ClientError, TimeoutError, OSError) with a short pause, while preserving the SSL certificate error path and _continue=None-on-failure behavior. Added a load_json() helper that raises BadfishException on malformed JSON and replaced the unwrapped json.loads sites in helpers/http_client.py and main.py with it, so a malformed response surfaces as a clear "Error reading <context> from host." error instead of a raw ValueError. fixes: #569
Codecov Report❌ Patch coverage is
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.
Fixes #569
Summary
Two robustness issues in the init/read-only path:
--retriesnever covered init requests.HTTPClientstoredself.retriesbutget_rawperformed a singlesession.getwith no retry loop, so transient failures during the initial requests (session discovery, authentication, resource enumeration) failed immediately instead of retrying.json.loadssites lackedValueErrorhandling. A malformed response surfaced as a rawValueErrortraceback instead of a clearBadfishException.Changes
src/badfish/helpers/http_client.pyget_rawnow wraps thesession.get+read in a retry loop honoringself.retries:aiohttp.ClientError,TimeoutError,OSError) with a 1s pause between attempts._handle_ssl_errorpath._continue=Truestill returnsNoneon failure; final failure raisesBadfishException("Failed to communicate with server.").post_request/patch_request/delete_requestsemantics unchanged.load_json(raw, context="response")helper that raisesBadfishException("Error reading <context> from host.")onValueError/TypeError.json.loadsinfind_session_uri.src/badfish/main.pyload_jsonand replaced the unwrappedjson.loads(raw.strip())sites with it (sites already intry/exceptwere left as-is):get_bootget_reset_typesfind_session_urifind_managers_resource(2 sites)check_schedule_job_status,check_job_statusTest evidence
tests/test_http_client.py: 39 passed (including newtest_get_raw_retries_then_succeeds,test_get_raw_retries_exhausted_raises,test_load_json_valid_returns_parsed,test_load_json_raises_on_invalid_json).