Skip to content

fix(cron): normalize repeat integer updates to dict format - #15590

Closed
liuhao1024 wants to merge 4 commits into
NousResearch:mainfrom
liuhao1024:fix/issue-15582-api-job-repeat-corrupt
Closed

liuhao1024 wants to merge 4 commits into
NousResearch:mainfrom
liuhao1024:fix/issue-15582-api-job-repeat-corrupt

Conversation

@liuhao1024

Copy link
Copy Markdown
Contributor

Summary

Fixes cron.jobs.update_job() to normalize raw integer repeat values from API PATCH requests into the internal dict format ({"times": n, "completed": count}). Previously, the API would forward raw integers directly to update_job(), causing mark_job_run() to crash with AttributeError: 'int' object has no attribute 'get'.

Root Cause

  • create_job() stores repeat as a dict: {"times": n, "completed": 0}
  • API PATCH /api/jobs/{job_id} accepts repeat as a raw integer (e.g., {"repeat": 2})
  • update_job() in cron/jobs.py merged updates directly without special handling for repeat
  • mark_job_run() assumed job["repeat"] is a dict and called .get("completed") on it
  • After an API update, job["repeat"] became an integer, causing mark_job_run() to crash on next run

Fix

Add repeat normalization in update_job(), mirroring the existing schedule field handling:

  • If repeat is an integer > 0, normalize to {"times": value, "completed": existing_count}
  • If repeat is <= 0, normalize to None (matching create_job() behavior)
  • Preserve existing completed count from job's current repeat state

Affected Files

  • cron/jobs.py - Add repeat_changed flag and normalization logic in update_job()
  • tests/gateway/test_api_server_jobs_update_repeat.py - Add regression coverage for update path

Regression Coverage

  • test_update_job_repeat_normalizes_integer_to_dict() - Verifies integer→dict normalization and completed preservation
  • test_update_job_repeat_negative_or_zero_is_rejected() - Verifies repeat <= 0 is normalized to None

Testing

# New regression tests pass
python -m pytest tests/gateway/test_api_server_jobs_update_repeat.py -xvs
# 2 passed

# Existing cron tests pass
bash scripts/run_tests.sh tests/cron/test_jobs.py
# 61 passed

# Existing API server tests pass
bash scripts/run_tests.sh tests/gateway/test_api_server_jobs.py
# 35 passed, 35 warnings

Closes #15582

…INSTALL_TIMEOUT

Increase the default npm install timeout for WhatsApp bridge from 60s
to 300s (5 minutes) to accommodate slower systems like Unraid NAS.
Make it configurable via WHATSAPP_NPM_INSTALL_TIMEOUT environment variable
for users who need even longer timeouts.

Closes NousResearch#14980
- Add 'path', 'old_string', 'new_string', and 'patch' to required list
- Update description to clarify mode-specific parameter requirements
- This addresses issue where LLMs would omit these parameters because
  they were not marked as required in the schema, even though they
  are required depending on the mode

Fixes NousResearch#15524
API PATCH /api/jobs/{job_id} accepts raw integer repeat values,
but update_job() forwards them directly without normalization. create_job()
stores repeat as dict ({"times": n, "completed": count}), and
mark_job_run() calls .get() on it. Updating with an integer
causes AttributeError on next run.

Normalize integer repeat values to dict format in update_job(),
matching create_job() behavior. Preserve existing completed count and
reject non-positive values (<= 0).

Fixes NousResearch#15582
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cron Cron scheduler and job management labels Apr 25, 2026
@liuhao1024

Copy link
Copy Markdown
Contributor Author

Closing inactive PR with no discussion. Opened 2026-04-25 with 0 comments. Will reopen if still relevant.

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

Labels

comp/cron Cron scheduler and job management P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API job repeat updates corrupt cron repeat state

2 participants