fix(exec): prevent -i/--image from consuming PROMPT (clap greedy variadic)
Bug
codex exec -i image.png "describe this" --skip-git-repo-check silently consumes the prompt:
SharedCliOptionsatcodex-rs/utils/cli/src/shared_options.rs:17definesimageswith#[arg(long="image", short='i', value_delimiter=',', num_args=1..)]- With
num_args=1..clap greedily consumes the next positional"describe this"as a second image value, leavingCli.prompt=None - Execution falls through to
read_prompt_from_stdin()inexec/src/lib.rs:2038and failsNo prompt provided via stdin
Reordering to codex exec "describe this" -i image.png works. Same root at codex-rs/cli/src/main.rs:289 for the TUI entrypoint.
Repro
- Before:
codex exec -i /tmp/a.png "hello"parses asimages=["/tmp/a.png", "hello"] prompt=None - After: same command parses as
images=["/tmp/a.png"] prompt=Some("hello")—commaa.png,b.pngand repeated-i a.png -i b.pngstill work
Fix (branch ready to cherry-pick)
Branch pushed to shoemoney/codex:fix/exec-image-clap-greedy @ 1cf455e:
codex-rs/utils/cli/src/shared_options.rs:17num_args=1..→num_args=1codex-rs/cli/src/main.rs:289same change- With
num_args=1+value_delimiter=','each-iconsumes exactly one arg that may contain comma-separated paths, so the following positionalPROMPTis not eaten.ForkArgs/ResumeArgsincodex-rs/exec/src/cli.rs:171,204already usenum_args=1as the correct pattern.
Diff: https://github.com/openai/codex/compare/main...shoemoney:fix/exec-image-clap-greedy
Evidence: local clap repro (before → images=[a.png, hello] prompt=None, after → images=[a.png] prompt=Some(hello)), cargo check -p codex-utils-cli 24s pass, cargo fmt --check pass.
Note
PR creation is blocked by collaborators_only (GraphQL FORBIDDEN + REST 404 on CreatePullRequest), so filing as an issue the maintainer can cherry-pick from (per CONTRIBUTING.md).
Written in conjunction with my pair programmer Claude.
1 Comment
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action