Skip to content

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

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-2b9eda1a
May 1, 2026
Merged

fix(auth): make provider config writes atomic#18217
teknium1 merged 1 commit into
mainfrom
hermes/hermes-2b9eda1a

Conversation

@teknium1

@teknium1 teknium1 commented May 1, 2026

Copy link
Copy Markdown
Contributor

Salvage of #16504 onto current main (cherry-picked clean, authorship preserved via rebase-merge).

Summary

Switches the two remaining raw-YAML config.yaml writes in hermes_cli/auth.py to the established atomic_yaml_write helper. An interrupted provider-switch or logout can no longer leave config.yaml partially written.

Changes

  • hermes_cli/auth.py: _update_config_for_provider and _reset_config_provider now call atomic_yaml_write (2 lines).
  • Added regression tests for both paths that raise OSError mid-write and assert the original config bytes survive.

Validation

  • Targeted tests (both new): 2 passed.
  • E2E: ran both real functions on a temp HERMES_HOME — correct config written, no tempfile leaks on success.
  • Repo-wide sibling audit: no other un-atomic write_text(yaml.safe_dump(...)) sites remain outside of tests.

Credit: @Yukipukii1 (commit authorship preserved).
Closes #16504.

@teknium1
teknium1 merged commit 5536651 into main May 1, 2026
10 of 11 checks passed
@teknium1
teknium1 deleted the hermes/hermes-2b9eda1a branch May 1, 2026 03:39
@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 May 1, 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.

3 participants