mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
fix(auth): preserve corrupt auth.json and warn instead of silently resetting
_load_auth_store() caught all parse/read exceptions and silently returned an empty store, making corruption look like a logout with no diagnostic information and no way to recover the original file. Now copies the corrupt file to auth.json.corrupt before resetting, and logs a warning with the exception and backup path.
This commit is contained in:
parent
c7d62b3fe3
commit
c599a41b84
1 changed files with 12 additions and 1 deletions
|
|
@ -743,7 +743,18 @@ def _load_auth_store(auth_file: Optional[Path] = None) -> Dict[str, Any]:
|
|||
|
||||
try:
|
||||
raw = json.loads(auth_file.read_text())
|
||||
except Exception as exc:
|
||||
corrupt_path = auth_file.with_suffix(".json.corrupt")
|
||||
try:
|
||||
import shutil
|
||||
shutil.copy2(auth_file, corrupt_path)
|
||||
except Exception:
|
||||
pass
|
||||
logger.warning(
|
||||
"auth: failed to parse %s (%s) — starting with empty store. "
|
||||
"Corrupt file preserved at %s",
|
||||
auth_file, exc, corrupt_path,
|
||||
)
|
||||
return {"version": AUTH_STORE_VERSION, "providers": {}}
|
||||
|
||||
if isinstance(raw, dict) and (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue