Skip to content

fix(doctor): read env vars from .env and default to China DashScope endpoint#18910

Closed
zons-zhaozhy wants to merge 2 commits into
NousResearch:mainfrom
zons-zhaozhy:fix/doctor-dashscope-china-env-and-default-url
Closed

fix(doctor): read env vars from .env and default to China DashScope endpoint#18910
zons-zhaozhy wants to merge 2 commits into
NousResearch:mainfrom
zons-zhaozhy:fix/doctor-dashscope-china-env-and-default-url

Conversation

@zons-zhaozhy

Copy link
Copy Markdown

Summary

hermes doctor API-key health checks had two bugs:

Bug 1: env vars from .env invisible to doctor

os.getenv() does not read ~/.hermes/.env. Keys and base URLs
stored only in .env (not exported to the shell) were invisible to all
16 api-key provider health checks.

Fix: Replace os.getenv() with get_env_value() for both API key
and base URL resolution.

Bug 2: DashScope default URL is international-only

The default health-check URL was
dashscope-intl.aliyuncs.com (international). China-region keys —
the vast majority of DashScope users — are valid only on
dashscope.aliyuncs.com. Doctor reported these as invalid.

Fix: Default to dashscope.aliyuncs.com (China). Users with
DASHSCOPE_BASE_URL set are unaffected.

Same Bug Class

Testing

23 existing doctor tests: all pass, zero regression.

Scope

  • 1 file: hermes_cli/doctor.py (+5 / -4)
  • Affects all 16 api-key provider health checks (env var reading)
  • DashScope default URL change

Fixes #18904

When DASHSCOPE_BASE_URL is not set and the first /models probe returns
401, automatically retry against the other region endpoint before
declaring the key invalid.

- China default: dashscope.aliyuncs.com
- Fallback: dashscope-intl.aliyuncs.com (and vice versa)
- If the key works on the fallback, prints a hint to set DASHSCOPE_BASE_URL
- get_env_value() is used for key/base_url lookup (respects .env file)

Fixes NousResearch#18910
@zons-zhaozhy zons-zhaozhy force-pushed the fix/doctor-dashscope-china-env-and-default-url branch from 6b651a8 to 9ad0bf7 Compare May 2, 2026 17:27
- Revert default URL to dashscope-intl.aliyuncs.com (matches provider
  registry in auth.py — running agent and doctor now probe the same
  endpoint by default).
- Move get_env_value import to module level (alongside other
  hermes_cli.config imports). No circular-import risk.
- Fallback hint now shows the exact DASHSCOPE_BASE_URL value the user
  should set, instead of a vague message.
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard area/config Config system, migrations, profiles labels May 2, 2026
@zons-zhaozhy zons-zhaozhy deleted the fix/doctor-dashscope-china-env-and-default-url branch May 4, 2026 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: hermes doctor reports valid China DashScope API key as invalid

3 participants