Skip to content

load_jobs() raises uncaught AttributeError on non-dict jobs.json, taking down the entire cron subsystem #36867

Closed

Description

@lunzen

Summary

If cron/jobs.json has a top-level JSON value that isn't an object (e.g. a bare array [...]), load_jobs() throws an uncaught AttributeError: 'list' object has no attribute 'get'. Because every cron code path goes through load_jobs(), this takes down the entire cron subsystem — the scheduler tick can't load any jobs, and the cronjob agent tool fails on every call — until the file is repaired by hand.

Version

hermes-agent 0.15.1 (commit 51c68d4)

Root cause

cron/jobs.py → load_jobs() (around lines 426–452):

with open(JOBS_FILE, 'r', encoding='utf-8') as f:
    data = json.load(f)
    return data.get("jobs", [])     # <-- AttributeError if data is a list, not a dict

The try only catches json.JSONDecodeError and IOError. A bare-list file is valid JSON, so json.load() succeeds and the .get() raises AttributeError, which propagates uncaught out of load_jobs(). The existing strict=False auto-repair path only handles control-character JSONDecodeError, not a wrong top-level shape.

Impact

  • Scheduler tick raises every cycle → no jobs run.
  • cronjob agent tool returns {"error": "'list' object has no attribute 'get'", "success": false} on list/add/edit → bot appears unable to create or modify schedules.
  • Fails closed and silently; requires manual file surgery to recover.

How it happens in practice

A jobs.json saved/edited outside save_jobs() (e.g. an admin editing it directly, an external tool, or a botched migration) can end up as a bare array instead of the expected {"jobs": [...], "updated_at": ...} wrapper. Distinct from #34600 / #32164, which are about the file being cleared/deleted rather than mis-shaped.

Suggested fix

Guard the shape and fold it into the existing repair/raise handling — accept a bare list as the jobs array (auto-repair by re-wrapping via save_jobs), and raise the graceful RuntimeError("Cron database corrupted...") for any other non-dict:

data = json.load(f)
if isinstance(data, list):           # tolerate/repair legacy or externally-written bare array
    save_jobs(data)
    logger.warning("Auto-repaired jobs.json (top-level was a list, expected object)")
    return data
if not isinstance(data, dict):
    raise RuntimeError(f"Cron database corrupted: top-level is {type(data).__name__}, expected object")
return data.get("jobs", [])

Activity

  1. added
    type/bugSomething isn't working
    P1High — major feature broken, no workaround
    comp/cronCron scheduler and job management
    on Jun 1, 2026
  2. Uraxii commented on Jun 1, 2026

    @Uraxii

    Pipeline fix opened: #36982

    Summary:

    • top-level list jobs.json now auto-repairs into canonical wrapped storage
    • scalar/null top-level JSON now raises graceful RuntimeError instead of AttributeError
    • regression coverage added for list repair + non-dict rejection

    Verified:

    • python -m pytest tests/cron/test_jobs.py -q
    • python -m pytest tests/cron -q

    — architect-designer / architect

  3. added a commit that references this issue on Jun 2, 2026
    d4b533d
  4. added a commit that references this issue on Jun 14, 2026
    620e0b4
  5. added a commit that references this issue on Jun 16, 2026
    6d1349c
  6. added a commit that references this issue on Jun 18, 2026
    5540f47
  7. added a commit that references this issue on Jun 25, 2026
    600d7c5
  8. added a commit that references this issue on Jul 2, 2026
    760b795
  9. added a commit that references this issue on Jul 13, 2026
    f26e173
  10. added a commit that references this issue on Jul 13, 2026
    f02829b
  11. added a commit that references this issue on Jul 21, 2026
    31b13d4
  12. added a commit that references this issue on Aug 7, 2026
    32ffec1
  13. added a commit that references this issue on Sep 3, 2026
    eb197d1
  14. added a commit that references this issue on Oct 6, 2026
    be5a83c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High — major feature broken, no workaroundcomp/cronCron scheduler and job managementtype/bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions