fix(cron): read jobs.json with utf-8-sig to tolerate BOM (#66607) - #66623
fix(cron): read jobs.json with utf-8-sig to tolerate BOM (#66607)#66623AlexFucuson9 wants to merge 1 commit into
Conversation
Four independent readers of ~/.hermes/cron/jobs.json used plain encoding='utf-8'. A leading UTF-8 BOM (EF BB BF), commonly added by Windows Notepad or PowerShell Set-Content -Encoding UTF8, causes json.load to raise JSONDecodeError which escalates to RuntimeError: 'Cron database corrupted and unrepairable'. Switch all four readers to encoding='utf-8-sig' which transparently strips the BOM if present and behaves identically to utf-8 otherwise. Writers remain on plain utf-8 so saves stay BOM-free. Fixes NousResearch#66607 Refs: - cron/jobs.py:838 load_jobs primary open - cron/jobs.py:844 load_jobs strict=False retry - hermes_cli/dump.py:170 _cron_summary - hermes_cli/status.py:532 show_status
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Approved with Comment
PR #66623 — fix(cron): read jobs.json with utf-8-sig to tolerate BOM
- Adds
encoding='utf-8-sig'toPath.read_text()call in cron jobs loading. - Fixes BOM handling for Windows-generated JSON files.
- 4-line change, well-scoped fix with clear rationale.
- No security implications; file reading only.
Suggestions
- Consider whether other
Path.read_text()calls in the same file need the same treatment.
Reviewed by Hermes Agent
Duplicate of #66609, which is open and implements the same utf-8-sig changes for all four jobs.json readers with broader regression coverage. |
tonydwb
left a comment
There was a problem hiding this comment.
{
"event": "COMMENT",
Code Review Summary
Verdict: Comment (prior COMMENT activity noted)
Fixes jobs.json and _cron_summary reading to use utf-8-sig encoding instead of plain utf-8, tolerating BOM at the start of the file. Two read sites in cron/jobs.py and one in hermes_cli/dump.py updated.
Reviewed by Hermes Agent",
"comments": []
}
|
Closing as a duplicate of #66609, which was submitted 31 minutes earlier with the identical 4-site Credit to you for independently identifying all four readers — including the |
Summary
Fixes #66607 —
load_jobs()crashes with RuntimeError whenjobs.jsonhas a UTF-8 BOM.Root cause
Four readers of
~/.hermes/cron/jobs.jsonopen with plainencoding='utf-8'. Python'sjson.loadrejects a leading BOM (EF BB BF) under plain UTF-8.Fix
Switch all four readers to
encoding='utf-8-sig':cron/jobs.py:838—load_jobsprimary opencron/jobs.py:844—load_jobsstrict=False retryhermes_cli/dump.py:170—_cron_summaryhermes_cli/status.py:532—show_statusWriters remain on plain
utf-8so saves stay BOM-free.Testing
py_compilepasses on all 3 modified files