Repository navigation
fix(cli): reject whitespace-only automation prompts on create and edit - #51847
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Severity of issue fixed: Medium Merge Risk:
|
The automation CLI accepted whitespace-only prompts because its string flag readers only checked length. Create, bot create and edit now read --prompt through shared helpers that reject blank text with invalid_argument and pass valid prompts through unchanged. On edit, --prompt= still keeps the saved prompt. Fixes stablyai#51846
ac78a31 to
d3300b4
Compare
ELI5
When you set up an automation from the command line, the prompt tells the agent what to do. Before this fix, a prompt made only of spaces was saved, so the automation ran with no instructions. The desktop editor already blocked this. Now the command line blocks it too and shows a clear error.
What Changed
orca automations create ... --prompt ' 'andorca automations edit <id> --prompt ' 'exited 0 and saved a whitespace-only prompt.invalid_argument: --prompt requires non-whitespace text, and nothing is written. Valid prompts are passed through exactly as typed (no trimming). On edit,--prompt=(empty) still keeps the saved prompt, as before.Mechanism:
src/cli/automations/automation-handler-flags.ts: newgetPromptFlag/getOptionalPromptFlag. They calltrim()only to check for blank text and return the original string.src/cli/automations/automations.ts:automations createandautomations editread--promptthrough these helpers.src/cli/automations/automation-bot-create.ts:--botcreate uses the same check before any write RPC.src/cli/automations/automation-handler-flags.test.ts: regression tests for create and edit.Why
The CLI read
--promptwithgetRequiredStringFlag/getOptionalStringFlag, which only checklength > 0. Validating in the CLI matches the desktop editor'sprompt.trim()check, and it works the same against old and new runtimes because the check runs before the RPC. Server-side validation (the sharedrequiredStringinsrc/shared/rpc-contract/automations/automation-params.ts, used by mobile and the plugin API) is a separate follow-up.Linked Issue
Fixes #51846
Visual Proof
CLI-only change, so this is terminal output from the development CLI against an isolated headless runtime (captured by @SeungWoonSong on Linux).
Before
After
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Reproduced on main: the new tests fail 2/2 there, because both create and edit reach the runtime with a blank prompt. They pass with this change.
Extra probes:
--botcreate with' \n'is rejected before any client call.--prompt=on edit keeps the saved prompt. Unicode whitespace (U+3000, NBSP, U+2003, CRLF+tab, U+FEFF) is rejected.' a 'and indented multiline Korean text are passed through exactly.vitest run src/cli/automations/: 7 files, 46 tests pass (macOS). The contributor also checked manually on Linux.On the 4 touched files: oxlint, oxfmt, anti-slop oxlint, code-quality oxlint and ast-grep are all clean, and the changed-code quality gate passes.
Performance
None. The check runs only once, while preparing a one-shot CLI create or edit command. It is not on a renderer, terminal, polling or startup path. Measured cost of the
trim()check: about 0.014 us for a typical prompt, and about 0.4-0.5 ms for an adversarial 1 MB prompt. It adds no I/O, subprocesses or fan-out.Risk
Level: Low. Scripts that pass a whitespace-only
--promptnow get aninvalid_argumenterror instead of saving an empty automation. That is the intended behavior. Older runtimes are unaffected because the check is CLI-side. To back it out, revert this commit.Review
Create, edit and
--botcreate share one prompt check that rejects whitespace-only input before any RPC write.Agent skill upstream boundary
Notes
automations watch-pr --prompt ' 'still passes because a deadline hint is appended before validation. This is harmless and out of scope. Server-side blank-prompt validation is a follow-up.Original fix by @SeungWoonSong in #51847 (authorship preserved).
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)