Skip to content

fix(doctor): use get_env_value for API keys and base URLs instead of os.getenv#23352

Closed
shellybotmoyer wants to merge 1 commit into
NousResearch:mainfrom
shellybotmoyer:fix/doctor-get-env-value-rebased
Closed

fix(doctor): use get_env_value for API keys and base URLs instead of os.getenv#23352
shellybotmoyer wants to merge 1 commit into
NousResearch:mainfrom
shellybotmoyer:fix/doctor-get-env-value-rebased

Conversation

@shellybotmoyer

Copy link
Copy Markdown
Contributor

fix(doctor): use get_env_value for API keys and base URLs instead of os.getenv

Problem

hermes_cli/doctor.py uses os.getenv() to read API keys and base URL env vars. os.getenv() only reads from os.environ, so values stored in ~/.hermes/.env (the standard location for API keys) are silently missed.

This causes:

  • API key blindspot: hermes doctor reports keys as "not configured" when they exist only in ~/.hermes/.env
  • Base URL fallback: providers with a custom BASE_URL in .env (like DASHSCOPE_BASE_URL) fall back to wrong registry defaults, causing false "invalid key" reports

Same pattern as #18757 (fixed in auth.py) — the os.getenv() vs get_env_value() inconsistency.

Fix

Replace os.getenv() with get_env_value() (with os.getenv() fallback) at 3 call sites:

  1. Line 1206 (_probe_openrouter): os.getenv("OPENROUTER_API_KEY")get_env_value("OPENROUTER_API_KEY") or os.getenv(...)
  2. Line 1339 (_probe_apikey_provider key loop): os.getenv(ev, "")get_env_value(ev) or os.getenv(ev, "")
  3. Line 1354 (_probe_apikey_provider base URL): os.getenv(base_env, "")get_env_value(base_env) or os.getenv(base_env, "")

Also imports get_env_value at the top of the file alongside existing hermes_cli.config imports.

Related


Supersedes #18989 (rebased onto current origin/main, avoiding the stale DIRTY branch).

…os.getenv

os.getenv() only reads os.environ, missing values stored in ~/.hermes/.env.
Same pattern as NousResearch#18757 (auth.py).
@alt-glitch alt-glitch added type/bug Something isn't working comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists labels May 10, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Automated hermes-sweeper review: this looks implemented on current main by the broader doctor startup env-load path.

Evidence:

  • hermes_cli/doctor.py:21-23 now loads the active Hermes .env before the doctor probes run: load_hermes_dotenv(hermes_home=_env_path.parent, project_env=PROJECT_ROOT / ".env").
  • hermes_cli/env_loader.py:237-243 loads the user env with override=True, so values from ~/.hermes/.env are present in os.environ for later os.getenv(...) calls.
  • The specific probe sites from this PR still live at hermes_cli/doctor.py:1597, hermes_cli/doctor.py:1731, and hermes_cli/doctor.py:1746, but they now execute after the .env file has been loaded into the process environment.
  • The relevant import-time env-loading code is present on current remote main as well; remote main was 4d6a133a9f5b38f11c7f8454ef0d9566e5736722 when checked.

Thanks for the clear report and for connecting it to the earlier get_env_value inconsistency. The underlying hermes doctor blindspot is covered on main now.

@teknium1 teknium1 closed this Jun 11, 2026
@teknium1 teknium1 added the sweeper:implemented-on-main Sweeper: behavior already present on current main label Jun 11, 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 P2 Medium — degraded but workaround exists sweeper:implemented-on-main Sweeper: behavior already present on current main type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants