Package archive builder deletes existing file with unsupported suffix under --force
维护者通常 1 天内回复
@akhil9tiet 已经在做这个了。
开始于 2026年10月28日。
评估
调研方向
阅读 scripts/codex_package/archive.py,追踪 write_archive() 从归档格式验证到文件删除的执行过程;scripts/codex_package/cli.py 展示了公开调用方。在 scripts/codex_package/test_archive.py 中添加一个回归用例,使用一个已有的、扩展名不受支持的文件,并设置 force=True;当命令拒绝该扩展名并保留文件时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- Rust
- 星标
- 131k
- 派生
- 20.7k
- 平均合并
- 1 分钟
- 30 天内合并 PR
- 997
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
openai/codex 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
Skill Creator quick validator rejects standard compatibility frontmatter可能已有人在做 @akhil9tiet 于 1 天前认领。 未关闭bug skills
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
bug CLI connectivity mcp
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
app bug
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复
-
app bug
难度 1/5 1 小时以内 新手友好度 65/100
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
quarto-dev/q2#1005 ·
维护者通常 1 天内回复
-
package-request
难度 2/5 1-3 小时 新手友好度 72/100
ScoopInstaller/Extras#19205 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
storytold/craft-libs#477 ·
维护者通常 1 天内回复
-
security
难度 2/5 1-3 小时 新手友好度 62/100
Waschndolos/open-clubmanager#185 ·
维护者通常 1 天内回复
-
r-bug
难度 1/5 1 小时以内 新手友好度 88/100
servo/rust-smallvec#844 ·
维护者通常 1 天内回复