Skip to content

fix: auto-repair jobs.json with invalid control characters (salvage #3517)#3537

Merged
teknium1 merged 1 commit intomainfrom
hermes/hermes-03f7719f
Mar 28, 2026
Merged

fix: auto-repair jobs.json with invalid control characters (salvage #3517)#3537
teknium1 merged 1 commit intomainfrom
hermes/hermes-03f7719f

Conversation

@teknium1
Copy link
Copy Markdown
Contributor

Summary

Salvage of #3517 by @zicochaos.

load_jobs() uses strict json.load() which rejects bare control characters (literal newlines, tabs, etc.) inside JSON string values. When a cron job prompt contains such characters — which happens when LLM output with newlines gets saved — the parser throws JSONDecodeError and the catch-all returns []. All cron jobs silently stop firing with no error logged.

Fix

On JSONDecodeError, retry with json.loads(strict=False) which accepts bare control characters. If jobs are recovered, auto-rewrite jobs.json via save_jobs() (which properly escapes everything via json.dump) and log a warning. Only fall back to empty list if the JSON is truly unrecoverable.

load_jobs() uses strict json.load() which rejects bare control characters
(e.g. literal newlines) in JSON string values. When a cron job prompt
contains such characters, the parser throws JSONDecodeError and the
function silently returns an empty list — causing ALL scheduled jobs
to stop firing with no error logged.

Fix: on JSONDecodeError, retry with json.loads(strict=False). If jobs
are recovered, auto-rewrite the file with proper escaping via save_jobs()
and log a warning. Only fall back to empty list if the JSON is truly
unrecoverable.
@teknium1 teknium1 merged commit d313a3b into main Mar 28, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant