Skip to content

fix(cli): force explicit utf-8 encoding for auth.json loading - #7411

Closed
Dusk1e wants to merge 1 commit into
NousResearch:mainfrom
Dusk1e:fix/auth-json-explicit-utf8-encoding
Closed

fix(cli): force explicit utf-8 encoding for auth.json loading#7411
Dusk1e wants to merge 1 commit into
NousResearch:mainfrom
Dusk1e:fix/auth-json-explicit-utf8-encoding

Conversation

@Dusk1e

@Dusk1e Dusk1e commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

Summary
This PR enforces explicit UTF-8 encoding when reading auth.json, fixing a cross-platform bug where authentication stores appeared empty on certain Windows locales.

Problem
The authentication store loader in hermes_cli/auth.py relied on the system's default locale encoding for reading auth.json. Since Hermes consistently writes this file in UTF-8, any Windows environment with a non-UTF-8 default codepage would fail to decode non-ASCII labels correctly. This resulted in the auth store being silently treated as empty or corrupted, breaking the login flow for international users.

Changes
hermes_cli/auth.py: Updated the read_text() call to explicitly use encoding="utf-8".

tests/hermes_cli/test_auth_provider_gate.py: Added a regression test that simulates a non-UTF8 locale environment to verify that _load_auth_store() only succeeds with explicit UTF-8 decoding.

Verification
The new regression test confirms the failure in the previous implementation and passes with the fix.

@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 area/auth Authentication, OAuth, credential pools labels Apr 29, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Subset of #15519 which adds encoding='utf-8' to 17 open() calls across 10 files. This PR covers only auth.json.

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the targeted regression coverage. The premise remains true on current main: _load_auth_store() uses auth_file.read_text() without an encoding at hermes_cli/auth.py:1087, while _save_auth_store() writes the same store with UTF-8 at hermes_cli/auth.py:1149. The proposed change directly aligns the reader with that writer, and the test exercises the real loader against a temporary HERMES_HOME.

This is an automated hermes-sweeper review.

@teknium1

teknium1 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Closing — auth.json loading is covered on main (utf-8-sig via #81967's #58158 salvage). Yours was one of the earliest reports of this class back in April — thanks for that.

@teknium1 teknium1 closed this Aug 8, 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 comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants