fix: prevent undefined directory creation when RUNNER_TEMP is not set (#461)

When running tests locally, process.env.RUNNER_TEMP is undefined, causing
the code to literally create "undefined/claude-prompts/" directories in
the working directory. Added fallback to "/tmp" following the pattern
already used in src/mcp/github-actions-server.ts.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Ashwin Bhat
2025-08-18 10:51:57 -07:00
committed by GitHub
parent e89411bb6f
commit f05d669d5f
2 changed files with 4 additions and 4 deletions

View File

@@ -836,7 +836,7 @@ export async function createPrompt(
modeContext.claudeBranch, modeContext.claudeBranch,
); );
await mkdir(`${process.env.RUNNER_TEMP}/claude-prompts`, { await mkdir(`${process.env.RUNNER_TEMP || "/tmp"}/claude-prompts`, {
recursive: true, recursive: true,
}); });
@@ -855,7 +855,7 @@ export async function createPrompt(
// Write the prompt file // Write the prompt file
await writeFile( await writeFile(
`${process.env.RUNNER_TEMP}/claude-prompts/claude-prompt.txt`, `${process.env.RUNNER_TEMP || "/tmp"}/claude-prompts/claude-prompt.txt`,
promptContent, promptContent,
); );

View File

@@ -45,7 +45,7 @@ export const agentMode: Mode = {
// TODO: handle by createPrompt (similar to tag and review modes) // TODO: handle by createPrompt (similar to tag and review modes)
// Create prompt directory // Create prompt directory
await mkdir(`${process.env.RUNNER_TEMP}/claude-prompts`, { await mkdir(`${process.env.RUNNER_TEMP || "/tmp"}/claude-prompts`, {
recursive: true, recursive: true,
}); });
// Write the prompt file - the base action requires a prompt_file parameter, // Write the prompt file - the base action requires a prompt_file parameter,
@@ -57,7 +57,7 @@ export const agentMode: Mode = {
context.inputs.directPrompt || context.inputs.directPrompt ||
`Repository: ${context.repository.owner}/${context.repository.repo}`; `Repository: ${context.repository.owner}/${context.repository.repo}`;
await writeFile( await writeFile(
`${process.env.RUNNER_TEMP}/claude-prompts/claude-prompt.txt`, `${process.env.RUNNER_TEMP || "/tmp"}/claude-prompts/claude-prompt.txt`,
promptContent, promptContent,
); );