Skip to content

fix(web_server): guard GATEWAY_HEALTH_TIMEOUT against invalid env values - #14751

Closed
sprmn24 wants to merge 1 commit into
NousResearch:mainfrom
sprmn24:fix/web-server-health-timeout-clean
Closed

fix(web_server): guard GATEWAY_HEALTH_TIMEOUT against invalid env values#14751
sprmn24 wants to merge 1 commit into
NousResearch:mainfrom
sprmn24:fix/web-server-health-timeout-clean

Conversation

@sprmn24

@sprmn24 sprmn24 commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

_GATEWAY_HEALTH_TIMEOUT = float(os.getenv("GATEWAY_HEALTH_TIMEOUT", "3")) runs at module level. Any non-numeric value (e.g. GATEWAY_HEALTH_TIMEOUT=abc) raises ValueError at import time, crashing the web server before it starts — with no useful error message.

Type of Change

  • Bug fix

Root Cause

float() is called directly on the env var with no guard. A misconfigured environment silently kills the entire dashboard process at startup.

Changes Made

  • Wrapped the float() call in try/except (ValueError, TypeError)
  • Logs a warning with the bad value using the existing _log logger
  • Falls back to 3.0 seconds so the server starts normally

How to Test

  1. Set GATEWAY_HEALTH_TIMEOUT=abc in ~/.hermes/.env
  2. Run hermes gateway with web dashboard enabled
  3. Before: server crashes at import with ValueError
  4. After: warning logged, server starts with 3.0s default

Checklist

  • Reuses existing _log logger already defined in the file
  • No new dependencies
  • Only touches the affected line

float(os.getenv(...)) at module level raises ValueError on any
non-numeric value, crashing the web server at import before it starts.

Wrap in try/except with a warning log and fallback to 3.0s.
@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 23, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Related to #11375 — same pattern of unguarded float() on env var.

@teknium1

Copy link
Copy Markdown
Contributor

Merged via PR #14756 — your commit 2beeedc was cherry-picked onto current main with authorship preserved. Thanks for the fix!

@teknium1 teknium1 closed this Apr 23, 2026
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