Package archive builder deletes existing file with unsupported suffix under --force
Maintainers usually reply within 1 day
@akhil9tiet is already working on this.
Since Oct 28, 2026.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
Research direction
Read scripts/codex_package/archive.py and trace write_archive() from archive format validation through file deletion; scripts/codex_package/cli.py shows the public caller. Add a regression case in scripts/codex_package/test_archive.py using an existing file with an unsupported suffix and force=True; done means the command rejects the suffix and preserves the file.
Written by the indexing model from the issue text.
Description
Summary
scripts/codex_package/archive.py::write_archive() deletes an existing --archive-output file when --force is supplied before validating the archive filename suffix. If the suffix is unsupported, the command fails with RuntimeError, but the pre-existing file has already been removed.
This is observable through the public package builder: scripts/codex_package/cli.py::archive_package() resolves each --archive-output and calls write_archive(..., force=args.force). The CLI accepts any path at argument parsing time.
Reproduction (isolated, no build required)
Using write_archive with an empty package directory and a pre-existing non-archive file:
from pathlib import Path
from tempfile import TemporaryDirectory
from codex_package.archive import write_archive
with TemporaryDirectory() as tmp:
root = Path(tmp)
package = root / "package"
package.mkdir()
output = root / "important.txt"
output.write_text("keep this data")
try:
write_archive(package, output, force=True)
except RuntimeError as exc:
print(exc) # Unsupported archive suffix ...
assert output.read_text() == "keep this data" # FAILS: FileNotFoundError
Set CODEX_REPO_ROOT to the repository root before importing the package, as required by codex_package.targets.
Expected
Reject unsupported archive suffixes without changing the existing output file.
Actual
write_archive runs archive_path.unlink() before archive_format_for_path(archive_path), so the original file is deleted even though no archive is written.
Evidence / verification
Reviewed scripts/codex_package/archive.py, scripts/codex_package/cli.py, scripts/codex_package/test_archive.py, and scripts/codex_package/test_cli.py at commit e742db9f7ba98e63e502b310857d49d047888518; rechecked the same order on the current default branch. An isolated local Python reproduction of the exact initial write_archive control flow confirmed the file disappears after the unsupported-suffix exception. Existing tests cover zstd resolution and version parsing, but not this failure case.
Suggested fix
Validate archive_format_for_path(archive_path) before any unlink/write side effects, and add a regression test asserting that a pre-existing file with an unsupported suffix is preserved when force=True.
No pull request has been submitted.
- Dominant language
- Rust
- Stars
- 131k
- Forks
- 20.7k
- Avg merge
- 1m
- Merged PRs (30d)
- 997
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing 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.
More from openai/codex
-
app bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
app bug
Difficulty 1/5 Under an hour Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
readme_toc.py generates duplicate fragment links for repeated headingsPossibly taken @akhil9tiet claimed this 2 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
openai/codex#57719 · 2 comments ·
Maintainers usually reply within 1 day
-
CLI enhancement TUI
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
compiler P4 perf
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
HerringtonDarkholme/hd-lang#1044 ·
Maintainers usually reply within 1 day
-
good first issue help wanted r-docs
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
servo/rust-smallvec#824 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
akitaonrails/ai-usagebar#552 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100