Skip to content

fix(s12): skip malformed durable jobs with non-string fields - #670

Open
shuhuNB515 wants to merge 1 commit into
shareAI-lab:mainfrom
shuhuNB515:fix/s12-durable-job-field-types
Open

shuhuNB515 wants to merge 1 commit into
shareAI-lab:mainfrom
shuhuNB515:fix/s12-durable-job-field-types

Conversation

@shuhuNB515

Copy link
Copy Markdown

Fixes #668

Problem

load_durable_jobs() in s12_cron_scheduler/code.py validates each persisted job so one corrupt entry can be skipped. However it called job.id.startswith(...) and job.prompt.strip() before checking that those fields were strings. An entry with a non-string field raised AttributeError, which was outside the per-item except (TypeError, ValueError), so loading aborted and even the valid jobs were lost. Because start_runtime_threads() calls load_durable_jobs() before starting the REPL, __main__ crashed before the agent could run.

Fix

  • Check isinstance(job.id, str) / isinstance(job.prompt, str) before using string methods.
  • Add AttributeError to the per-item handler, so a non-string cron is also skipped with the same warning.
  • Sync the embedded s12 source in web/src/data/generated/versions.json (asserted byte-identical to code.py).

Verification (real module)

case before after
one valid job + job with id: 12345 AttributeError aborts load, 0 jobs loaded warning, 1 valid job loaded
malformed JSON store warning, no jobs unchanged
valid durable store loads unchanged

python3 -m pytest tests -q: 503 passed, 118 subtests passed.


Disclosed AI assistance: found and fixed during an AI-assisted review; both failure modes were reproduced against the real module before and after the change.

CronJob fields loaded from .scheduled_tasks.json were validated
with .startswith()/.strip() before type checks. A saved job with a
non-string id, prompt, or cron raised AttributeError, which escaped the
per-item handler and crashed load_durable_jobs() (and therefore startup).
Validate field types first and widen the handler to AttributeError so one
bad entry is skipped like any other corrupt job. Sync the embedded s12
snapshot in versions.json.

Disclosed AI assistance: found during an AI-assisted review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

s12: a saved cron job with non-string fields crashes load_durable_jobs and prevents startup

1 participant