fix(exec): prevent -i/--image from consuming PROMPT (clap greedy variadic)
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 125k
- Forks
- 19.4k
- PR merge metrics
- PR metrics pending
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the image argument definitions in codex-rs/utils/cli/src/shared_options.rs and codex-rs/cli/src/main.rs, then compare the num_args pattern in codex-rs/exec/src/cli.rs. Run the cited clap reproduction and cargo check -p codex-utils-cli; done means positional prompts remain intact while comma-separated and repeated image arguments still parse correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 25/100