fix(cron): guard against null deliver/repeat/schedule in cron list#32916
Open
annguyenNous wants to merge 1 commit into
Open
fix(cron): guard against null deliver/repeat/schedule in cron list#32916annguyenNous wants to merge 1 commit into
annguyenNous wants to merge 1 commit into
Conversation
When a cron job has null deliver, repeat, or schedule fields
(common when jobs are created without explicit delivery),
hermes cron list crashes with TypeError:
can only join an iterable
'NoneType' object has no attribute 'get'
Fix by using `or {}` / `or []` pattern instead of .get(key, default)
which only applies the default when key is missing, not when
key exists with null value.
Fixes NousResearch#32896
Contributor
|
Clean fix. I hit the same null deliver field crash on my instance (#32896 is the same root) -- the job.get('deliver') returning None instead of defaulting to ['local'] is the core issue. Using 'or ['local']' instead of 'get(..., ['local'])' is the right call here because get() with a mutable default is a pitfall (the default gets shared across calls). Same pattern on repeat_info and schedule_display. |
Collaborator
19 tasks
Contributor
Contributor
|
Superseded by #20264 |
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #32896
When a cron job has
nulldeliver,repeat, orschedulefields (common when jobs are created without explicit delivery),hermes cron listcrashes with:Root Cause
.get("key", default)only applies the default when the key is missing. When the key exists with valueNone(null in JSON),.get()returnsNoneand the default is ignored.Fix
Use
or defaultpattern instead of.get(key, default):job.get("deliver", ["local"])→job.get("deliver") or ["local"]job.get("repeat", {})→job.get("repeat") or {}job.get("schedule_display", ...)→job.get("schedule_display") or (...)This ensures
Nonevalues are also replaced with the default.Changes
hermes_cli/cron.py: 3 lines changed