Repository navigation
fix(codex): guard mktemp failures in codex mode templates - #2966
Closed
SomSamantray wants to merge 1 commit into
Closed
SomSamantray wants to merge 1 commit into
SomSamantray wants to merge 1 commit into
Conversation
Every mktemp assignment in the three codex mode templates
(review-mode, consult-mode, challenge-mode) was unguarded.
bin/gstack-paths deliberately best-effort-creates $TMP_ROOT and
defers failure discovery to the caller's own write attempt, so an
unwritable $TMP_ROOT made these mktemp calls silently yield an
empty variable. The next command then redirected stderr to 2>"",
which failed before codex even ran, misattributing the failure to
codex instead of the missing temp file.
Guard every mktemp assignment with a loud exit, matching the
existing repo convention (redact-doc.ts, ship/pr-body.md.tmpl,
gstack-upgrade/SKILL.md.tmpl, supabase/verify-rls.sh,
build-app.sh). challenge-mode's ${TMPERR:-$(mktemp ...)} wrapper
is preserved unchanged; verified live that the guard composes
correctly with the parameter-expansion default.
Regenerated codex/sections/*.md from the updated .tmpl sources
per the repo's SKILL.md generation workflow.
Fixes garrytan#2881
|
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 |
Contributor
Author
Contributor
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.

Why
Every
codexmode (/codex review,/codex consult,/codex challenge) creates its stderr/response/prompt temp files withmktemp "$TMP_ROOT/..."and never checks whether that call actually succeeded.bin/gstack-pathsresolves$TMP_ROOTwith a deliberately best-effortmkdir -p ... || true, explicitly punting failure discovery to "the caller's own write attempt." When$TMP_ROOTturns out to be unwritable (no permission, disk full, a read-only sandbox),mktempfails silently, the variable is empty, the next command redirects stderr to2>"", and the user gets a codex-attributed error instead of the real cause. This guards everymktempassignment in the three codex mode templates with a loud, correctly-attributed exit, matching the guard shape the repo already uses at five other call sites (redact-doc.ts,ship/pr-body.md.tmpl,gstack-upgrade/SKILL.md.tmpl,build-app.sh,verify-rls.sh).Live evidence
bun run test(full free suite) also ran; it reports 37 pre-existing failures in 9 files, all in unrelated subsystems (CSO/Docker watchdog, gbrain MCP timeouts, macOS codesigning, PTY setup). Confirmed viagit stashthat the same failures occur on unmodifiedupstream/mainbefore this branch's changes — not introduced by this PR.Scope
codex/sections/{review,consult,challenge}-mode.md.tmpl(source templates, hand-edited) + their generatedcodex/sections/{review,consult,challenge}-mode.mdcounterparts (regenerated viabun run gen:skill-docs --host all), plus a new#2881test block intest/regression-pr1169-mktemp-fallbacks.test.ts.${TMPERR:-$(mktemp ...)}guard composition, the adjacent static-validation suites (skill-validation,mktemp-portability,regression-issue2091),bun run skill:check(no template/generated drift), and the fullbun run testsuite cross-checked againstupstream/mainfor pre-existing failures./codex review|consult|challengeinvocation against a real unwritable$TMP_ROOTend-to-end (would need a live Codex CLI session + a deliberately broken sandbox); the static + runtime-guard tests cover the failure-propagation contract instead.Liveness proof (required for external contributors)
Attached as a PR comment —
GSTACK PRtyped live in my terminal.Checklist
GSTACK PRtyped live into a real surface) or PR author is @garrytan (owner exemption)