openai / openai/codex

fix(exec): prevent -i/--image from consuming PROMPT (clap greedy variadic)

Open
#40,695 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug CLI exec
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:

  • SharedCliOptions at codex-rs/utils/cli/src/shared_options.rs:17 defines images with #[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, leaving Cli.prompt=None
  • Execution falls through to read_prompt_from_stdin() in exec/src/lib.rs:2038 and fails No 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 as images=["/tmp/a.png", "hello"] prompt=None
  • After: same command parses as images=["/tmp/a.png"] prompt=Some("hello")comma a.png,b.png and repeated -i a.png -i b.png still 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:17 num_args=1..num_args=1
  • codex-rs/cli/src/main.rs:289 same change
  • With num_args=1 + value_delimiter=',' each -i consumes exactly one arg that may contain comma-separated paths, so the following positional PROMPT is not eaten. ForkArgs/ResumeArgs in codex-rs/exec/src/cli.rs:171,204 already use num_args=1 as 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.