fix(timeouts): guard load_config() call against runtime exceptions - #16318
Merged
Conversation
Both get_provider_request_timeout() and get_provider_stale_timeout() wrapped the load_config import in try/except ImportError but left the actual load_config() call unprotected. A corrupt config file, YAML parse error, or permission failure would raise instead of returning None safely. Move load_config() inside the try block so any exception returns None.
Exception already covers ImportError; (ImportError, Exception) was a cosmetic wart from the bugfix. Pure no-op.
4 tasks
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.
Salvage of #16232 by @sprmn24.
Summary
get_provider_request_timeout()andget_provider_stale_timeout()wrapped only theload_configimport in try/except. The actualload_config()call sat outside.load_config()callsensure_hermes_home()before its own internal YAML-parse guard — so PermissionError on mkdir, RuntimeError in managed mode, or any other bootstrap failure would propagate up into ~14 call sites in run_agent.py and crash the agent loop on every API call.Changes
hermes_cli/timeouts.py: moveload_config()inside the try block in both helpers, broaden toexcept Exception(follow-up commit dropped redundant(ImportError, Exception)).Validation
E2E verified by monkey-patching
load_configto raise PermissionError — both helpers return None cleanly.Closes #16232. Contributor authorship preserved via rebase merge.