Skip to content

fix(doctor): recognize KIMI_CN_API_KEY and handle kimi-cn probe safely#9734

Closed
sqsge wants to merge 1 commit into
NousResearch:mainfrom
sqsge:codex/fix-doctor-kimi-cn-probe
Closed

fix(doctor): recognize KIMI_CN_API_KEY and handle kimi-cn probe safely#9734
sqsge wants to merge 1 commit into
NousResearch:mainfrom
sqsge:codex/fix-doctor-kimi-cn-probe

Conversation

@sqsge

@sqsge sqsge commented Apr 14, 2026

Copy link
Copy Markdown

Summary

  • add KIMI_CN_API_KEY to doctor's provider env hints
  • make the Kimi / Moonshot (China) doctor probe null-safe when base_env is not set
  • add regression coverage for both behaviors

Why

hermes doctor appears to have two doctor-only issues for the kimi-coding-cn provider:

  1. KIMI_CN_API_KEY is not included in doctor's provider env hints, so China-only Kimi setups can be misclassified as missing provider credentials
  2. the Kimi China probe entry uses base_env=None, but the later probe loop still calls os.getenv(_base_env, "") unconditionally, which can raise TypeError: str expected, not NoneType

This PR keeps the fix intentionally narrow and limits it to the diagnostic layer in hermes_cli/doctor.py.

Fixes #9716

Tests

I added regression coverage in tests/hermes_cli/test_doctor.py for:

  • recognizing KIMI_CN_API_KEY as a configured provider env
  • ensuring the Kimi China doctor probe no longer crashes when base_env is None

Local verification:

  • python -m pytest -o addopts='' tests/hermes_cli/test_doctor.py -q
  • result: 19 passed

The repository's default pytest configuration includes -n, which is not available in this local environment, so I ran the same test file with addopts disabled.

@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 provider/kimi Kimi / Moonshot labels Apr 26, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Related to #15583 (kimi-coding-cn false unknown-provider warning in doctor). Both target kimi-cn doctor probes but fix different symptoms: this PR fixes env key detection and null base_env crash, #15583 fixes alias resolution causing false unknown-provider.

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the contribution! Both fixes in this PR are already on main via an independent commit that landed around the same time.

  • KIMI_CN_API_KEY was added to _PROVIDER_ENV_HINTS in hermes_cli/doctor.py (line 48)
  • The null-safe _base_env guard (if _base_env else "") was applied at line 968

This was merged as commit 70611879d and shipped in v2026.4.16.

Closing as already implemented. (Automated hermes-sweeper review)

@teknium1 teknium1 closed this Apr 27, 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 provider/kimi Kimi / Moonshot type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: hermes doctor does not detect KIMI_CN_API_KEY and breaks the Kimi / Moonshot (China) probe

3 participants