openai / openai/codex-action

Custom codex-home fails when the target directory does not exist yet

Open Beginner friendly
#135 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
1.2k
Forks
170
PR merge metrics
No merged PRs in 30d

Description

Summary

Supplying codex-home with a path that does not already exist can make the action fail during proxy startup, because the custom path is returned without creating the directory first.

The default Codex home path is explicitly created, but the user-supplied path takes an earlier return.

Reproduction

Use a fresh path as the action's Codex home:

- uses: openai/codex-action@v1
  with:
    openai-api-key: ${{ secrets.OPENAI_API_KEY }}
    codex-home: ${{ runner.temp }}/fresh-codex-home
    prompt: Say hello.

where $RUNNER_TEMP/fresh-codex-home does not exist before the action starts.

Current resolveCodexHome behaviour is effectively:

if (inputCodexHome != null) {
  return expandTilde(inputCodexHome);
}
...
const codexHome = path.join(os.homedir(), ".codex");
await fs.mkdir(codexHome, { recursive: true });
return codexHome;

The action then derives:

$CODEX_HOME/$GITHUB_RUN_ID.json

and starts codex-responses-api-proxy --server-info <that path>. With a missing parent directory, the server-info file cannot be created and the wait step eventually reports that the proxy did not write server info.

Expected behavior

codex-home is documented as the directory to use as Codex home. The action should ensure that directory exists before any proxy/config steps attempt to write inside it, just as it already does for the default home.

For safety-strategy: unprivileged-user, a newly created custom home should be created as the configured codex-user, rather than becoming runner-owned and immediately inaccessible to Codex.

Suggested fix

After resolving the home path and before deriving/writing server state, ensure the directory exists:

  • ordinary strategies: mkdir -p -- "$CODEX_HOME";
  • unprivileged-user: sudo -u "$CODEX_USER" -- mkdir -p -- "$CODEX_HOME".

Existing directories should be left untouched so the action does not unexpectedly change ownership or permissions supplied by the caller.

Impact

This is setup reliability. A valid custom path currently works only if callers know to pre-create it, and the resulting failure is reported later as a proxy/server-info problem rather than as a Codex-home setup problem.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the resolveCodexHome entry point and trace where the resolved path is used to derive server state before proxy startup. Ensure a missing custom directory is created with the appropriate strategy and user, while existing directories remain untouched; verify the proxy can write its server-info file for a fresh codex-home path.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
ci-cd
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.