fix(env-loader): defer _APPLIED_HOMES.add() until after secret loading succeeds - #40614
fix(env-loader): defer _APPLIED_HOMES.add() until after secret loading succeeds#40614liuhao1024 wants to merge 2 commits into
Conversation
…g succeeds Move _APPLIED_HOMES.add(home_key) from before config loading to after all early-return guards pass. Previously, if _load_secrets_config() raised or bitwarden was disabled, the home path was permanently marked as applied — all subsequent calls became no-ops even after the user fixed the configuration. Fixes NousResearch#40597
|
Thanks for identifying the applied-home ordering bug. The premise remains present on current main: Problems
Suggested changes
Automated hermes-sweeper review. |
|
Resolved by #69056 — and an apology is owed here: you submitted this fix on June 6, well before #69056, and our duplicate sweep missed it when building the fix (we searched symptom keywords but not the issue number — a process failure on our side, now noted). Your placement of the mark-after-guards was exactly right; #69056 implements the same semantics on the SecretSource orchestrator path that superseded the apply shim your branch targeted, plus keeps fetch ERRORS marking the home so startup doesn't re-print failures 3-5x. Credit to you as first submitter for #40597. Thanks @liuhao1024, and sorry for the overlap. |
What does this PR do?
Moves
_APPLIED_HOMES.add(home_key)from before secret loading to after all early-return guards pass, so that a failed config load does not permanently prevent retrying on subsequent calls.Related Issue
Fixes #40597
Type of Change
Changes Made
hermes_cli/env_loader.py: Removed premature_APPLIED_HOMES.add(home_key)before config loading; added it after all early-return guards (config load, enabled check, import check) pass successfullytests/test_bitwarden_secrets.py: Added 2 regression tests — one verifying home is NOT marked after failed load, one verifying it IS marked after successful loadHow to Test
pytest tests/test_bitwarden_secrets.py -v— all 38 tests pass including the 2 new regression testspytest tests/hermes_cli/test_env_loader.py -v— all 6 existing tests passsecrets.bitwarden.enabled: truewith a broken config, fix it, restart — secrets should now load on retryChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/ACode Intelligence
hermes_cli/env_loader.py:_apply_external_secret_sources(callers: cli.py, run_agent.py, gateway/run.py via load_hermes_dotenv)