fix(codex-import): empty find must not fall through to cwd - #2482
Open
tranthanhnhatkhoa wants to merge 1 commit into
Open
fix(codex-import): empty find must not fall through to cwd#2482tranthanhnhatkhoa wants to merge 1 commit into
tranthanhnhatkhoa wants to merge 1 commit into
Conversation
`find ... -print | xargs ls -t | head -1` runs `ls -t` with NO OPERANDS
when find matches nothing, and `ls -t` with no operands lists the current
directory. LATEST therefore holds a random entry from wherever the
caller happened to be, the `[ -z "$LATEST" ]` guard below passes, and the
script "imports" that path.
Run from the repo root with no Codex sessions present:
IMPORTED: 0 events from 1 session(s)
instead of NO_SESSIONS. The tool reports a successful import of a
directory it picked up off the floor.
Switched to `-exec ls -t {} +`, which never runs the command when
nothing matched. Chose that over `xargs -r` deliberately: `-r` is
GNU-only, this repo targets macOS, and there is no existing `xargs -r`
use in bin/ or scripts/ to follow.
Verified:
empty dir -> blank (guard now fires, prints NO_SESSIONS)
populated dir -> newest rollout-*.jsonl, unchanged
bash -n clean
test/gstack-codex-session-import.test.ts 6 pass 1 fail -> 7 pass 0 fail
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
This was referenced Aug 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
bin/gstack-codex-session-import:67When
findmatches nothing,xargsstill runsls -t— with no operands — andls -twith no operands lists the current directory. SoLATESTholds a random entry from wherever the caller happened to be, the[ -z "$LATEST" ]guard on the next line passes, and the script imports that path.Run from the repo root on a machine with no Codex sessions:
instead of
NO_SESSIONS. It reports a successful import of a directory it picked up off the floor. Reproduced directly:The fix
-exec ls -t {} +never runs the command when nothing matched.Chose that over
xargs -rdeliberately:-ris GNU-only, this repo targets macOS, and there is no existingxargs -rinbin/orscripts/to follow.Verified
Three more sites, deliberately not touched here
The same pattern appears in three other places, and two are user-visible:
scripts/resolvers/review.ts:859PLANbecomes a random.mdfrom cwd —/reviewreads the wrong file as the planscripts/resolvers/preamble/generate-context-recovery.ts:15scripts/resolvers/preamble/generate-context-recovery.ts:24LATEST_CHECKPOINTpoints at a random file, which the skill is then told to readI fixed them locally and backed it out: those two files are resolvers, so changing them regenerates 44
SKILL.mdfiles and the golden-file baselines. That is a call for you to make, not something to smuggle into a one-line bug fix. The same-exec ... +substitution applies verbatim to all three, followed bybun run gen:skill-docs.Environment: bun 1.3.14, Ubuntu 24.04.4 LTS,
main@960c3a8d(v1.60.2.0).🤖 Generated with Claude Code
https://claude.ai/code/session_01H3KRWmyJnSvzzxeooDxuU3