openai / openai/codex-plugin-cc
adversarial-review: EISDIR crash when untracked directories exist + input size overflow
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 33.3k
- Forks
- 2.3k
- PR merge metrics
- No merged PRs in 30d
Description
Bug Report
Environment
- codex-cli: 0.116.0
- codex-plugin-cc: 1.0.1
- Node.js: v22.12.0
- OS: macOS Darwin 24.4.0
Description
/codex:adversarial-review crashes with EISDIR: illegal operation on a directory, read when the working tree contains untracked directories. After fixing the EISDIR issue, it hits a secondary problem: Input exceeds the maximum length of 1048576 characters due to collecting all untracked file contents without a total size cap.
/codex:review works fine because it uses the native app server reviewer (runAppServerReview) which bypasses collectReviewContext. The adversarial-review path calls collectReviewContext → collectWorkingTreeContext → formatUntrackedFile, which has two issues.
Root Cause 1: EISDIR
In scripts/lib/git.mjs, formatUntrackedFile() does not check for directories before calling fs.readFileSync():
// line 136-149
function formatUntrackedFile(cwd, relativePath) {
const absolutePath = path.join(cwd, relativePath);
const stat = fs.statSync(absolutePath);
// Missing: stat.isDirectory() check
if (stat.size > MAX_UNTRACKED_BYTES) {
return `...`;
}
const buffer = fs.readFileSync(absolutePath); // EISDIR if directory
...
}
git ls-files --others --exclude-standard can return paths that resolve to directories (e.g., in nested structures or when .gitignore doesn't fully exclude node_modules/).
Suggested Fix for EISDIR
function formatUntrackedFile(cwd, relativePath) {
const absolutePath = path.join(cwd, relativePath);
const stat = fs.statSync(absolutePath);
if (stat.isDirectory()) {
return `### ${relativePath}\n(skipped: directory)`;
}
if (stat.size > MAX_UNTRACKED_BYTES) {
...
Root Cause 2: Input Size Overflow
After fixing EISDIR, collectWorkingTreeContext successfully reads all untracked files but the combined content exceeds the 1MB Codex input limit. This happens in repos with large untracked trees (e.g., node_modules/, build artifacts, many temp files).
/codex:review avoids this because the native reviewer handles file collection internally with its own limits.
Suggested Fix for Input Size
Add a cumulative size budget to collectWorkingTreeContext, stopping untracked file collection once a threshold is reached (similar to how MAX_UNTRACKED_BYTES caps individual files).
Steps to Reproduce
- Have a repo with untracked directories (e.g.,
node_modules/not fully gitignored, ortmp/with many files) - Run
/codex:adversarial-review - Observe
EISDIRcrash (or after EISDIR fix, observe input size overflow)
Workaround
Ensure all large untracked directories are in .gitignore before running adversarial-review.
Contributor guide
No contributing guide indexed for this repository
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.
Research direction
Start in scripts/lib/git.mjs by reading formatUntrackedFile and collectWorkingTreeContext, then reproduce /codex:adversarial-review with an untracked directory and a large untracked tree. Done means directories no longer cause EISDIR and collection stops before the combined input exceeds the limit.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100