fix(cron): import run_job in _run_cron_tracked to fix NameError - #1312
fecolinhares wants to merge 1 commit into
Conversation
Manual cron job execution from the WebUI crashed with NameError because run_job was called without being imported in the function scope. This adds the missing import at the start of _run_cron_tracked(), allowing manual cron runs to execute correctly. Fixes nesquena#1310
|
Confirmed the diff and the matching bug surface in master:
Looks safe to merge. Closes #1310. 🤖 Automated triage via nesquena-hermes |
…esquena#1312) _run_cron_tracked() runs inside a worker thread (threading.Thread), so it cannot see the caller's local import of run_job from _handle_cron_run. Moved the import into _run_cron_tracked and removed the now-redundant import from the route handler. Fixes nesquena#1312, Fixes nesquena#1310
|
Thanks for jumping on #1310 so quickly, @fecolinhares! 🙏 Closing this in favor of #1317 which lands the same one-line fix plus AST-based regression tests in The fix from #1317 is going out as part of release v0.50.245, with credit also pointing back to #1312 and #1329 in the changelog as parallel discoveries. Really appreciate you investigating the worker-thread scope angle in your write-up — it matched the actual root cause exactly. Looking forward to the next one! |
Thinking Path
_run_cron_tracked()inapi/routes.pycron.scheduler.run_job()to track running staterun_job(job)without importing it firstNameError: name 'run_job' is not definedwhen clicking "Run Now" on any cron jobWhat Changed
Added one import statement inside
_run_cron_tracked():Files modified:
api/routes.py(+2 lines: import + blank line)Why It Matters
Verification
python -m py_compile api/routes.py— passespytest tests/ -k cron— 45 passed, 9 skipped (require running agent)run_jobwithout import in the file (searched entire routes.py)Risks / Follow-ups
Model Used
AI Usage Disclosure
Fixes #1310