Skip to content

fix(auth): make provider config writes atomic - #16504

Closed
Yukipukii1 wants to merge 1 commit into
NousResearch:mainfrom
Yukipukii1:fix/auth-config-atomic-write
Closed

fix(auth): make provider config writes atomic#16504
Yukipukii1 wants to merge 1 commit into
NousResearch:mainfrom
Yukipukii1:fix/auth-config-atomic-write

Conversation

@Yukipukii1

Copy link
Copy Markdown
Contributor

Summary

This fixes two non-atomic config.yaml writes in the auth provider flow.

Previously, Hermes wrote config.yaml directly in:

  • _update_config_for_provider()
  • _reset_config_provider()

That meant an interrupted write during provider switch or logout could leave
config.yaml partially written or corrupted.

This patch switches both paths to atomic_yaml_write(...), aligning them with
the repo’s existing config persistence hardening.

Changes

  • use atomic_yaml_write in hermes_cli/auth.py for provider update writes
  • use atomic_yaml_write in hermes_cli/auth.py for provider reset/logout writes
  • add regression tests covering both paths

Why this matters

Provider selection and logout are user-facing config mutation paths. If either
write is interrupted, Hermes can end up with a broken config.yaml, which is a
bad failure mode for a small persistence path that already has an atomic helper.

Testing

Ran:

scripts/run_tests.sh \
  tests/hermes_cli/test_model_provider_persistence.py::TestProviderPersistsAfterModelSave::test_update_config_for_provider_uses_atomic_yaml_write \
  tests/hermes_cli/test_auth_commands.py::test_reset_config_provider_uses_atomic_yaml_write

2 passed

@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/auth Authentication, OAuth, credential pools area/config Config system, migrations, profiles labels Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/auth Authentication, OAuth, credential pools 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.

2 participants