TypeScript SDK rejects local image filenames beginning with a hyphen

Open Beginner friendly
#60,991 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript
Domain
cli

Research direction

The SDK constructs CLI arguments in sdk/typescript/src/exec.ts around lines 173–180. Read that argument construction and locate the fresh and resumed-turn argument tests. Update the image argument handling so a filename beginning with a hyphen is passed intact, then run those tests and confirm they cover -sample.png.

Written by the indexing model from the issue text.

Description

bug CLI exec windows-os

What issue are you seeing?

A valid relative image filename beginning with - cannot be attached through the TypeScript SDK. The SDK passes --image and the filename as separate arguments, and the CLI interprets the filename as an option rather than the image value.

Reproduction

In a directory containing a valid PNG named -sample.png, run a turn with the SDK:

import { Codex } from "@openai/codex-sdk";

const thread = new Codex().startThread({
  workingDirectory: process.cwd(),
  skipGitRepoCheck: true,
});
await thread.run([
  { type: "text", text: "Describe this image." },
  { type: "local_image", path: "-sample.png" },
]);

The CLI exits with code 2 and reports that a value is required for --image. The failure happens before the model request. Changing the path to ./-sample.png is a workaround.

I reproduced this with the actual bundled SDK and Codex CLI 0.167.0-alpha.4.1 on Windows, using a local mock Responses server. normal.png and ./-sample.png completed and reached the mock; -sample.png failed before a request. As an independent control, codex exec --image=-sample.png ... accepted the same file and completed against the mock.

Expected behavior

The SDK should pass a literal path intact even when it starts with a hyphen. One option is to use the single-argument --image=<path> form; add fresh and resumed-turn argument tests. This is distinct from #60587, which concerns commas in image paths.

The SDK constructs the arguments here. Source checked at 6bfdc75f0d9e6fae313234f694839866d7c63c39.

Dominant language
Rust
Stars
135k
Forks
21.4k
Avg merge
1m
Merged PRs (30d)
995

Getting set up

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.

More from openai/codex

All issues in openai/codex

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.