fix(doctor): use get_env_value for API keys and base URLs instead of os.getenv#18989
Closed
shellybotmoyer wants to merge 1 commit into
Closed
fix(doctor): use get_env_value for API keys and base URLs instead of os.getenv#18989shellybotmoyer wants to merge 1 commit into
shellybotmoyer wants to merge 1 commit into
Conversation
…os.getenv os.getenv() only reads os.environ, missing values stored in ~/.hermes/.env. doctor would report keys as missing and base URLs as default when they were configured in .env. Same pattern as NousResearch#18757 fix in auth.py.
Collaborator
Collaborator
|
Likely duplicate of #18910. |
Contributor
Author
|
Superseded by #23352, which rebases this fix onto current main. Closing in favor of the clean replacement. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
hermes_cli/doctor.pyusesos.getenv()to read API keys and base URL env vars, which only reads fromos.environ. Values stored in~/.hermes/.env(the standard location for API keys) are silently missed.This causes:
~/.hermes/.envBASE_URLin.env(likeDASHSCOPE_BASE_URL) fall back to wrong registry defaults, causing false "invalid key" reportsSame pattern as #18757 (fixed in auth.py) —
os.getenv()vsget_env_value()inconsistency.Fix
Replace
os.getenv()withget_env_value()(withos.getenv()fallback) at 3 call sites:openrouter_key = os.getenv("OPENROUTER_API_KEY")→_get_env_value("OPENROUTER_API_KEY") or os.getenv("OPENROUTER_API_KEY")_key = os.getenv(_ev, "")in provider loop →_get_env_value(_ev) or os.getenv(_ev, "")_base = os.getenv(_base_env, "")for base URL →_get_env_value(_base_env) or os.getenv(_base_env, "")The fallback to
os.getenv()ensures values injected directly into the process environment (e.g., Docker, CI) still work.Related
auth.pydoctor.py line 1122 (_base = os.getenv(_base_env, "")) still uses os.getenv