Skip to content

fix(apps): reject non-string cron execution selectors - #16420

Merged
chenmingwei23 merged 1 commit into
mainfrom
fix/cron-selector-types-10053
Oct 3, 2026
Merged

chenmingwei23 merged 1 commit into
mainfrom
fix/cron-selector-types-10053

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Replaces #10053 by @leonlaiyc

Problem / Motivation

Goal: Reject a cron manifest whose command or script execution selector is present but not a string, instead of silently discarding it and running the job as a default-agent message.

An app manifest cron with a present non-string command or script selector is currently coerced to an empty string. The manifest then validates, and the scheduler sees neither execution selector, so the job falls through to the default-agent mode and runs its message instead of rejecting the corrupted input.

Why it matters

A malformed non-string cron command or script is currently accepted and coerced into absence. The scheduler can then silently run the job in default-agent mode instead of rejecting corrupted manifest input, changing execution semantics rather than merely emitting a validation warning.

Not a goal

  • Does not change the established null-means-absent convention: a JSON null still means "selector absent", not an error.
  • Does not alter runtime cron execution, scheduling, or the command/script mutual-exclusion rule beyond the type check at manifest-validation time.

What changed (motivation → approach → change)

  • Symptom: a cron with command: 7 (or script: 7) parses to an empty selector and runs as a default-agent message job rather than being rejected.
  • Root cause: CronEntry.from_dict normalized command/script through _str_or_empty, which coerces any non-string (including a present 7) to "", erasing the type error before validation runs.
  • Change: route both selectors through the existing _str_or_flagged helper (already used for timezone), which records a present non-null non-string value as a cron type violation, and add command/script to _CRON_FIELD_JSON_TYPES so validation emits an actionable expected-type error. The null-means-absent path is preserved.

Backwards compatibility

Breaking: a manifest that today supplies a present non-string command or script (e.g. a number or object) is now rejected at validation instead of silently coerced to absent. Writer sweep on origin/main @ a36c1d7: no in-repo manifest or test writes a non-string command/script; all app-bundle manifests under src/kiro_crew/apps/**/manifest.* use string or null selectors. A JSON null (the generator's spelling of "absent") is unaffected.

Readers of cron command/script after validation:

  • Reader: src/kiro_crew/apps/manifest.py:CronEntry.from_dict — app install — still works: a string or null selector normalizes exactly as before; only a present non-string now flags.
  • Reader: scheduler cron registration (consumes CronEntry.command/.script as strings) — cron — still works: it only ever sees validated string/empty selectors, which is unchanged for all currently-accepted input.

Tests

  • test_cron_execution_selector_non_string_is_rejected[command|script]: a present 7 leaves the selector empty AND produces a wrong-JSON-type validation error (red before the fix: no error was raised).
  • test_cron_null_execution_selector_remains_absent[command|script]: a JSON null selector raises no error, locking in the null-means-absent convention.
  • Full test/test_app_manifest.py: 235 passed.

Manual verification

N/A — manifest parsing and the admission error are deterministic unit-level contracts covered by the tests above.

Related Issues

Closes #9895.

Pattern harvest

Rule candidate: review-prompt. Pattern: manifest execution selectors that are present and non-null must be type-checked before any normalization that can coerce them into absence (_str_or_empty erases the type error; use _str_or_flagged).

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

A malformed command or script selector was silently erased during manifest parsing, changing the cron into a default-agent job. Record the type violation so validation rejects the manifest while preserving null as the supported absent spelling.

Refs #9895
@iamwhatever
iamwhatever requested a review from a team as a code owner October 3, 2026 07:54
@iamwhatever iamwhatever added the drive-to-green PR claimed by drive-to-green pipeline label Oct 3, 2026
@iamwhatever iamwhatever self-assigned this Oct 3, 2026
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 3, 2026
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 1baae99db2163c9ee9f232b00b2222a0ec770deb — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Check whether an app that is already installed with a non-string command/script now fails to validate on reload or upgrade, rather than only at install time.

[DESIGN-REVIEWED] 1baae99

Description read

[DESCRIPTION-READ] 56b3d9e6df901959a979e9bbbf23e5e3dec919f9bfa380ae5f5b8d43a4216e64

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 1baae99db2163c9ee9f232b00b2222a0ec770deb — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: PASS

One case to check before merge: a non-string cron_expr next to a valid every is still dropped without any error by _str_or_empty (manifest.py:389). That's out of goal, but it's the only remaining field that can silently change when a job runs.

What this change ships

Inventory (3 items) — 3 justified

Intent: an app author whose cron manifest has a mistyped command/script gets a validation error, not a job that quietly runs as a default-agent message. FIX (closes #9895).

  1. A cron whose command or script is present but not a string (e.g. 7) is now rejected with a "wrong JSON type" error, where before it ran as a message job — justified
  2. A null command/script still counts as absent and raises no error — justified
  3. The manifest reference documents the rejection on both selector rows — justified

[FIRST-PRINCIPLES-REVIEWED] 1baae99

Description read

[DESCRIPTION-READ] e3918437b3d81fb140a385d20af3991d5f1ba6552e627250a6476dfceb9d9dbf

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 1baae99db2163c9ee9f232b00b2222a0ec770deb — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 1baae99

Verdict parsed from the review's SHA-scoped output markers for commit 1baae99db2163c9ee9f232b00b2222a0ec770deb.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 1baae99db2163c9ee9f232b00b2222a0ec770deb: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 1baae99db2163c9ee9f232b00b2222a0ec770deb and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 1baae99

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 1baae99db2163c9ee9f232b00b2222a0ec770deb: <one-sentence reason>

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 3, 2026
@chenmingwei23
chenmingwei23 merged commit dc860c6 into main Oct 3, 2026
116 of 124 checks passed
@chenmingwei23
chenmingwei23 deleted the fix/cron-selector-types-10053 branch October 3, 2026 17:08
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 3, 2026
@dwu96 dwu96 removed the drive-to-green PR claimed by drive-to-green pipeline label Oct 3, 2026
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.

App manifest cron selectors (command/script) coerce non-strings instead of rejecting — mode fallthrough

4 participants