Skip to content

fix(cli): don't hang on stdin for destructive ops in non-interactive sessions#463

Open
PeterGuy326 wants to merge 1 commit into
DingTalk-Real-AI:mainfrom
PeterGuy326:fix/cli-noninteractive-destructive-confirm
Open

fix(cli): don't hang on stdin for destructive ops in non-interactive sessions#463
PeterGuy326 wants to merge 1 commit into
DingTalk-Real-AI:mainfrom
PeterGuy326:fix/cli-noninteractive-destructive-confirm

Conversation

@PeterGuy326

Copy link
Copy Markdown
Collaborator

Problem

Destructive compat commands (e.g. calendar room delete, calendar participant delete) unconditionally read a yes/no confirmation from stdin when --yes is not passed. In a non-interactive session (pipe / CI / test harness / AI agent), stdin hits EOF immediately, so the command:

  • prints the confirmation prompt + Operation cancelled to stderr
  • leaves stdout empty (no JSON)
  • returns exit code 0

The destructive operation silently does not run, yet reports success. Any -f json caller parsing the empty stdout treats it as a failure. This is the root cause of the calendar failures in the cli_to_mcp evaluation.

Reproduce (before)

printf '' | dws calendar room delete --event FAKE --rooms FAKE -f json ; echo "exit=$?"
# stderr: "⚠️  This is a destructive operation. Confirm? (yes/no): Operation cancelled"
# stdout: (empty)
# exit=0

Fix

Before falling into the interactive prompt, detect a non-interactive stdin (os.Stdin is not a character device) and return a structured validation error instructing the caller to pass --yes, instead of hanging on / EOF-ing the prompt.

After

printf '' | dws calendar room delete --event FAKE --rooms FAKE -f json ; echo "exit=$?"
# structured JSON validation error: "...re-run with --yes to confirm..."
# exit=non-zero

printf '' | dws calendar room delete --event FAKE --rooms FAKE --yes -f json
# bypasses the gate, reaches real execution (business API error for the fake event)

Interactive TTY sessions are unaffected — they still get the confirmation prompt.

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.

1 participant