fix: clean temporary Codex output after failed runs - #138
Open
sylvesterkaczmarek wants to merge 3 commits into
Open
fix: clean temporary Codex output after failed runs#138sylvesterkaczmarek wants to merge 3 commits into
sylvesterkaczmarek wants to merge 3 commits into
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
Author
|
I have read the CLA Document and I hereby sign the CLA |
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.
Summary
Make the composite action own the implicit
--output-last-messagefile lifecycle so temporary output is removed even whencodex execfails.Fixes #137.
Problem
When the user does not set
output-file, the bundledrun-codex-exechelper creates a temporary directory internally.That directory is cleaned from
finalizeExecution(), butfinalizeExecution()is only reached after a zero exit code. A non-zero Codex exit rejects immediately, leaving the action-owned temporary directory behind.On ephemeral hosted runners this is mostly noise. On long-lived self-hosted runners, repeated failed runs can accumulate abandoned temporary directories.
Fix
Move ownership of the implicit output path to the composite-action boundary:
output-file, create a managed temporary directory before invoking Codex.output.mdpath through the helper's existing explicit--output-fileoption.always()cleanup step afterRun codex exec.Because the helper sees an explicit output path, it no longer creates its own untracked temporary output directory. The action can therefore clean the managed directory after success, validation errors, process failures, or non-zero Codex exits.
User-provided
output-filepaths are not managed or deleted.Privilege handling
The helper preserves the existing safety-strategy boundary:
mkdtemp/ recursivermunder the current runner identity;unprivileged-usercreates the directory throughsudo -u <codex-user> -- mktemp -d, so Codex can write the final message;sudo rm -rfbecause the directory is owned by the unprivileged account.drop-sudoremains safe because its managed directory is runner-owned and cleanup does not require sudo after privilege removal.Regression coverage
Added dependency-free Node tests covering:
sudo -u <user>preparation and privileged cleanup forunprivileged-user;unprivileged-useris selected withoutcodex-user.The unprivileged test uses a fake
sudoexecutable and a real temporary directory, so both command construction and actual cleanup are exercised without elevated test privileges.Validation
main(c385816875cc2fc8e033ed9d1cba96f8c331210e);src/change, so the checked-indist/main.jsremains valid;Risk
Low. The existing
run-codex-execinterface is unchanged. Explicit user output files keep their current behavior. The only behavioral change is that the action supplies and later removes its own temporary output path when the caller leftoutput-fileempty.