Skip to content

fix: validate prompt and working paths before setup - #142

Open
sylvesterkaczmarek wants to merge 3 commits into
openai:mainfrom
sylvesterkaczmarek:fix/early-path-preflight
Open

fix: validate prompt and working paths before setup#142
sylvesterkaczmarek wants to merge 3 commits into
openai:mainfrom
sylvesterkaczmarek:fix/early-path-preflight

Conversation

@sylvesterkaczmarek

Copy link
Copy Markdown

Summary

Validate local path inputs immediately after Node setup so missing prompt-file or invalid working-directory values fail before proxy startup and irreversible host changes.

Fixes #141.

Problem

prompt-file is not read until the final run-codex-exec helper starts, and working-directory is not meaningfully checked until Codex is invoked.

That ordering means a simple path typo can be reported only after the action has already performed setup that may include:

  • package installation;
  • Responses API proxy startup;
  • Linux user-namespace/AppArmor changes;
  • the default irreversible drop-sudo step.

For example:

- uses: openai/codex-action@v1
  with:
    openai-api-key: ${{ secrets.OPENAI_API_KEY }}
    prompt-file: .github/does-not-exist.md

currently reaches readFile(prompt.path, "utf8") near the end of the action, after those setup steps.

Fix

Add a dependency-free filesystem preflight immediately after Node setup.

It validates:

  • a non-empty prompt-file exists, is not a directory, and is readable by the action process;
  • the effective working-directory (input or github.workspace) exists and is a directory.

Whitespace-only prompt-file remains equivalent to an empty value, matching the action's existing input normalization behavior.

The existing runtime checks remain in place, so races or filesystem changes after preflight still fail normally.

Scope

This intentionally does not preflight output-schema-file or output-file: those paths are consumed by Codex and can have different ownership/relative-path semantics under unprivileged-user and --cd. This PR only validates paths whose interpretation is unambiguous at the composite-action boundary.

Regression coverage

Added six Node-stdlib tests covering:

  1. readable prompt file + valid working directory;
  2. empty/whitespace prompt-file with inline prompt usage;
  3. missing prompt-file;
  4. directory passed as prompt-file;
  5. missing working-directory;
  6. file passed as working-directory.

Validation

  • all 6/6 focused behavioural tests pass locally;
  • branch is based directly on current upstream main (c385816875cc2fc8e033ed9d1cba96f8c331210e);
  • branch is 0 commits behind upstream;
  • production manifest change is only 8 added lines;
  • no files under src/ change, so the checked-in dist/main.js bundle remains valid.

Risk

Low. These invalid paths already fail today. The change moves deterministic filesystem failures earlier, before the action mutates runner state.

@github-actions

github-actions Bot commented Aug 18, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@sylvesterkaczmarek

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid prompt-file and working-directory paths fail only after setup side effects

1 participant