Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Package archive builder deletes existing file with unsupported suffix under --force

Open Beginner friendly
#57,727 2 comments 0 reactions 0 assignees View on GitHub

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
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python, rust
Domain
cli, testing

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

bug
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

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.