Skip to content

fix(cron): whitelist cron update_job fields so typos don't silently persist (#67625) - #67646

Closed
Ahmett101 wants to merge 2 commits into
NousResearch:mainfrom
Ahmett101:fix/67625-cron-update-whitelist
Closed

fix(cron): whitelist cron update_job fields so typos don't silently persist (#67625)#67646
Ahmett101 wants to merge 2 commits into
NousResearch:mainfrom
Ahmett101:fix/67625-cron-update-whitelist

Conversation

@Ahmett101

Copy link
Copy Markdown
Contributor

Summary

update_job in cron/jobs.py and the dashboard adapter _normalize_dashboard_cron_updates silently persisted any key in the update payload — including typos like promt instead of prompt. The API returned 200 and persisted the garbage key; downstream consumers then depended on it. Stale-client custom fields accumulated in jobs.json with no audit trail.

This change rejects unknown keys with a clear error instead of silently storing them. Existing valid fields continue to work; an explicit metadata field is reserved for integration-specific bookkeeping so users have a sanctioned place to keep extension data instead of inventing top-level keys.

Changes

  • cron/jobs.py: add _VALID_JOB_FIELDS whitelist (all valid job attrs + description, attach_to_session, provider_snapshot, model_snapshot, metadata); update_job now raises ValueError("Cron job update contains unknown field(s): ..."). The existing immutable-id guard is preserved as a distinct 400-class error.
  • hermes_cli/web_server.py: add _DASHBOARD_ALLOWED_UPDATE_FIELDS mirroring the whitelist; _normalize_dashboard_cron_updates rejects unknown keys with a 422 listing every offending field, before the IPC round-trip. id is allowed as a payload key here so the existing immutable guard's 400 remains actionable.
  • tests/cron/test_jobs.py: 3 new regression tests — typo reject, multiple-unknown listing, metadata escape-valve.
  • tests/hermes_cli/test_web_server_cron_profiles.py: 1 new test — dashboard surfaces a 422 with the offending key listed, original field untouched.

How to Test

pytest tests/cron/test_jobs.py -q

144/144 passed (3 new: test_update_job_rejects_unknown_field_typo, test_update_job_rejects_multiple_unknown_keys, test_update_job_accepts_explicit_metadata)

pytest tests/hermes_cli/test_web_server_cron_profiles.py -q

22/22 passed (1 new: test_update_cron_job_rejects_unknown_field_as_422)

Decision rationale (issue is needs-decision)

Three modes were on the table in the issue: warn-first, reject-only, strip-and-proceed — and whether ad-hoc keys deserve an explicit metadata vent. Reject-only is the strict choice the issue favours for the typo class, and a preserved metadata escape valve keeps the legitimate-integration use case working without letting accidental keys slip in. Lowest ambiguity: caller learns immediately when a key is unknown, but has a sanctioned place for genuine extension data.

Checklist

  • Tests pass — 144/144 + 22/22
  • Follows Conventional Commits
  • Changes scoped to this fix only
  • Cross-platform impact assessed (Linux / macOS / WSL2 / Windows / Termux) — none
  • profile-safe paths used
  • .env not used for non-credential settings

Risk & Impact: Low. Strict validation: previously-passing update payloads with typos or stale-client custom keys will now raise ValueError (caller sees 4xx instead of false-positive 200). External integrations relying on ad-hoc keys must either update to whitelisted fields or move their extension data under metadata. Issue explicitly flags this as a breaking-change risk and asks for the audit — this PR documents the reject semantics clearly so the audit can compare against the whitelist.

Type: Bug fix
Closes: #67625

@alt-glitch alt-glitch added type/bug Something isn't working comp/acp Agent Communication Protocol adapter comp/cron Cron scheduler and job management comp/cli CLI entry point, hermes_cli/, setup wizard area/config Config system, migrations, profiles P2 Medium — degraded but workaround exists needs-decision Awaiting maintainer decision before any implementation sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state labels Jul 19, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Related to #67625 and #66881: this branch combines the cron unknown-field validation with an independent ACP durable-session listing fix. Please split or explicitly review both scopes together.

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

Labels

area/config Config system, migrations, profiles comp/acp Agent Communication Protocol adapter comp/cli CLI entry point, hermes_cli/, setup wizard comp/cron Cron scheduler and job management needs-decision Awaiting maintainer decision before any implementation P2 Medium — degraded but workaround exists sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: update_job silently persists unknown keys with no validation

2 participants