Skip to content

fix(cli): reject whitespace-only automation prompts on create and edit - #51847

Merged
nwparker merged 1 commit into
stablyai:mainfrom
SeungWoonSong:fix/cli-reject-blank-automation-prompt
Nov 28, 2026
Merged

nwparker merged 1 commit into
stablyai:mainfrom
SeungWoonSong:fix/cli-reject-blank-automation-prompt

Conversation

@SeungWoonSong

@SeungWoonSong SeungWoonSong commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Before: orca automations create ... --prompt ' ' and orca automations edit <id> --prompt ' ' exited 0 and saved a whitespace-only prompt.
  • After: both exit 1 with 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: new getPromptFlag / getOptionalPromptFlag. They call trim() only to check for blank text and return the original string.
  • src/cli/automations/automations.ts: automations create and automations edit read --prompt through these helpers.
  • src/cli/automations/automation-bot-create.ts: --bot create 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 --prompt with getRequiredStringFlag / getOptionalStringFlag, which only check length > 0. Validating in the CLI matches the desktop editor's prompt.trim() check, and it works the same against old and new runtimes because the check runs before the RPC. Server-side validation (the shared requiredString in src/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
$ orca-dev automations create --name 'Daily review' --trigger daily --provider codex --repo path:/tmp/orca-prompt-yzvdg1q6/project --disabled --prompt '   ' --json
{"ok": true, "automation": {"id": "944f0889-15ce-4239-8f9c-8a7e00822e16", "prompt": "   ", "enabled": false}}
exit=0

$ orca-dev automations edit 74ecda66-5981-453a-8e21-08e205798ef2 --prompt '   ' --json
{"ok": true, "automation": {"id": "74ecda66-5981-453a-8e21-08e205798ef2", "prompt": "   ", "enabled": false}}
exit=0
After
$ orca-dev automations create --name 'Daily review' --trigger daily --provider codex --repo path:/tmp/orca-prompt-yzvdg1q6/project --disabled --prompt '   ' --json
{"ok": false, "error": {"code": "invalid_argument", "message": "--prompt requires non-whitespace text"}}
exit=1

$ orca-dev automations edit 4cda0a74-afa7-44ac-877f-becb44202a04 --prompt '   ' --json
{"ok": false, "error": {"code": "invalid_argument", "message": "--prompt requires non-whitespace text"}}
exit=1

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: --bot create 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 --prompt now get an invalid_argument error 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 --bot create share one prompt check that rejects whitespace-only input before any RPC write.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

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

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The CLI now rejects automation prompts that contain only whitespace. Required and optional prompt flag readers validate prompt content and return valid text unchanged. Automation create and edit commands use these readers, as does the bot-create path. Tests cover whitespace-only rejection for create and edit, and unchanged valid prompt text for create.

Severity of issue fixed: Medium

Merge Risk: Minimal · up to ac78a

The CLI now rejects whitespace-only automation prompts on create and edit with an invalid_argument error, and valid prompt text passes through unchanged. The change is small, covered by tests for both rejections, and easy to revert, so merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Linked Issues check Passed [#51846] requires CLI automation create and edit to reject whitespace-only prompts with invalid_argument, and a rejected edit must leave the saved prompt intact. At head, requirePromptText in src/cl…
Out of Scope Changes check Passed All changed areas serve the objective of #51846. The changes are: a new prompt helper set in automation-handler-flags.ts; use of that helper for create in automations.ts and for the --bot create path …
Title check Passed The title "fix(cli): reject whitespace-only automation prompts on create and edit" names the main change: the CLI now rejects whitespace-only --prompt values on automations create and edit. The change…
Description check Passed The description follows the repository template. It covers ELI5, What Changed (before and after plus mechanism), Why (including the alternative of server-side validation), Linked Issue (Fixes #51846),…
Full details: Linked Issues check

Explanation

[#51846] requires CLI automation create and edit to reject whitespace-only prompts with invalid_argument, and a rejected edit must leave the saved prompt intact. At head, requirePromptText in src/cli/automations/automation-handler-flags.ts throws RuntimeClientError('invalid_argument', '--prompt requires non-whitespace text') when prompt.trim() is empty. getPromptFlag (create, and the bot create path in automation-bot-create.ts) applies this to the required flag. getOptionalPromptFlag (edit in automations.ts) applies it only when the flag is present. getOptionalStringFlag returns undefined for an empty value, so --prompt= keeps the saved prompt. The check runs while the updates or create object is built, before automation.create or automation.update is called, so a rejected edit or create makes no RPC write. Valid prompts are returned unchanged, untrimmed. The issue's coding requirements are met by the code at head. Note: the diff tool was unavailable, so the changed test file was not read. The test claims in the PR description were not independently verified; they do not change this verdict because the issue requires behavior, not specific tests.

Full details: Out of Scope Changes check

Explanation

All changed areas serve the objective of #51846. The changes are: a new prompt helper set in automation-handler-flags.ts; use of that helper for create in automations.ts and for the --bot create path in automation-bot-create.ts; use of the optional helper for edit in automations.ts; and tests in automation-handler-flags.test.ts. Server-side RPC validation is not part of this PR, and the issue does not require it. The PR description states that this is deferred. No unrelated changes were identified in the summary or in the inspected head files. The changed test file and the diff itself were not read because the diff tool was unavailable, so this verdict rests on the summary and the inspected head files.

Full details: Title check

Explanation

The title "fix(cli): reject whitespace-only automation prompts on create and edit" names the main change: the CLI now rejects whitespace-only --prompt values on automations create and edit. The changeset adds getPromptFlag and getOptionalPromptFlag, wires them into create and edit, and adds tests. The title covers the core behavior, and its scope matches the code and the linked issue.

Full details: Description check

Explanation

The description follows the repository template. It covers ELI5, What Changed (before and after plus mechanism), Why (including the alternative of server-side validation), Linked Issue (Fixes #51846), Visual Proof (before and after terminal output), Testing, Performance, Risk with level and revert path, Agent skill boundary, and the checklist. The Review and Notes sections are filled in. Minor gaps: the AI Disclosure section is left as template text, and the final lint/typecheck/test/build checklist item is unchecked. Those items do not block the check.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 14683167-dd79-41a7-9b46-12f43b453f94
Commits

Reviewing files that changed from the base of the PR and between aa7691f and ac78a31.

Files selected for processing: 4

  • src/cli/automations/automation-bot-create.ts
  • src/cli/automations/automation-handler-flags.test.ts
  • src/cli/automations/automation-handler-flags.ts
  • src/cli/automations/automations.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

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
@nwparker
nwparker force-pushed the fix/cli-reject-blank-automation-prompt branch from ac78a31 to d3300b4 Compare November 28, 2026 17:53
@nwparker nwparker changed the title fix(cli): reject blank automation prompts fix(cli): reject whitespace-only automation prompts on create and edit Nov 28, 2026
@nwparker
nwparker merged commit 104d5c5 into stablyai:main Nov 28, 2026
59 of 60 checks passed
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.

[Bug]: CLI accepts whitespace-only automation prompts

2 participants