{"record":{"id":"9eb3f2fcbdb67c2f","repo":"NousResearch/hermes-agent","slug":"cron-database-corrupted-and-unrepairable-e","errorCode":null,"errorMessage":"Cron database corrupted and unrepairable: {e}","messagePattern":"Cron database corrupted and unrepairable: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"cron/jobs.py","lineNumber":1097,"sourceCode":"    \"\"\"Load all jobs from storage.\"\"\"\n    jobs_file = _current_cron_store().jobs_file\n    ensure_dirs()\n    # Stamp BEFORE reading (fail-safe direction — see _record_load_stamp):\n    # a sibling write racing this load leaves the stamp older than disk, so\n    # the save-path merge runs instead of being wrongly skipped.\n    pre_read_stamp = _jobs_file_stamp(jobs_file)\n    if not jobs_file.exists():\n        _record_load_stamp(None)\n        return []\n\n    try:\n        data, _strict_retry = _parse_jobs_file(jobs_file)\n    except IOError as e:\n        logger.error(\"IOError reading jobs.json: %s\", e)\n        raise RuntimeError(f\"Failed to read cron database: {e}\") from e\n    except Exception as e:\n        logger.error(\"Failed to auto-repair jobs.json: %s\", e)\n        raise RuntimeError(f\"Cron database corrupted and unrepairable: {e}\") from e\n\n    # Validate the top-level JSON shape: accept a dict (expected) or a bare\n    # list (auto-repair). Anything else (str/number/null) is corruption that\n    # would otherwise raise an uncaught AttributeError on ``.get()`` and take\n    # down the whole cron subsystem.\n    if isinstance(data, dict):\n        jobs = data.get(\"jobs\", [])\n        if _strict_retry and jobs:\n            # Hit control-character corruption — rewrite with proper escaping.\n            save_jobs(jobs)\n            logger.warning(\"Auto-repaired jobs.json (had invalid control characters)\")\n        _record_load_stamp(pre_read_stamp)\n        return jobs\n    if isinstance(data, list):\n        # Bare array — likely saved/edited outside save_jobs(). Wrap it back\n        # into the expected {\"jobs\": [...]} structure.\n        if data:\n            save_jobs(data)","sourceCodeStart":1079,"sourceCodeEnd":1115,"githubUrl":"https://github.com/NousResearch/hermes-agent/blob/c896c09c42910c584c4c7d2325b58c14713ea42c/cron/jobs.py#L1079-L1115","documentation":"Error \"Cron database corrupted and unrepairable: {e}\" thrown in NousResearch/hermes-agent.","triggerScenarios":"Thrown at cron/jobs.py:1097 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Restore the cron database from a backup, or remove it to start fresh (losing jobs).","Report the corruption if it recurs after recreation."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"c896c09c42910c584c4c7d2325b58c14713ea42c","analyzedAt":"2026-08-14T17:18:01.089Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}