Skip to content

fix(timeouts): guard load_config() call against runtime exceptions - #16232

Closed
sprmn24 wants to merge 1 commit into
NousResearch:mainfrom
sprmn24:fix/timeouts-load-config-exception
Closed

fix(timeouts): guard load_config() call against runtime exceptions#16232
sprmn24 wants to merge 1 commit into
NousResearch:mainfrom
sprmn24:fix/timeouts-load-config-exception

Conversation

@sprmn24

@sprmn24 sprmn24 commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Both get_provider_request_timeout() and get_provider_stale_timeout() in hermes_cli/timeouts.py wrapped the load_config import in try/except ImportError but left the actual load_config() call unprotected outside the block.

Type of Change

  • Bug fix

Root Cause

If load_config() raises at runtime (corrupt YAML, parse error, permission failure), the exception propagates up instead of returning None safely — breaking any provider timeout resolution silently.

Changes Made

  • Moved load_config() call inside the try block in both functions
  • Broadened the except clause to (ImportError, Exception) to catch all failure modes
  • Both functions now return None safely on any config load failure

How to Test

  1. Write malformed YAML to ~/.hermes/config.yaml
  2. Call get_provider_request_timeout("openai")
  3. Before: raises exception
  4. After: returns None safely

Checklist

  • No new dependencies
  • Both functions fixed with the same pattern
  • Only touches the try/except blocks in hermes_cli/timeouts.py

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.
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/cli CLI entry point, hermes_cli/, setup wizard labels Apr 26, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Merged via #16318 — your commit (16e243e) is on main with authorship preserved. I added a small follow-up dropping the redundant ImportError from (ImportError, Exception) since Exception already covers it. Thanks for the patch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants