From b7e4162a708cbc0c739e47a207f4cf090e84d07d Mon Sep 17 00:00:00 2001 From: Christopher Buckley Date: Wed, 18 Feb 2026 20:57:34 +0900 Subject: [PATCH] Fix empty API key preflight to avoid ENOENT server-info failure Root cause: the Read server info step was allowed to run when a prompt was provided even if openai-api-key was empty, which skipped proxy startup and later failed with a misleading ENOENT while reading .json. Fix: add an explicit preflight validation step (for prompt runs) that trims openai-api-key and fails fast with a clear actionable error when empty; and gate Read server info on openai-api-key presence so downstream read logic cannot run on invalid startup paths. Behavior: valid-key flows remain unchanged; missing/blank key now fails early with a clear message instead of a missing server-info JSON error. --- action.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index d83acc2..0b23cab 100644 --- a/action.yml +++ b/action.yml @@ -155,6 +155,16 @@ runs: server_info_file="${{ steps.resolve_home.outputs.codex-home }}/${{ github.run_id }}.json" echo "server_info_file=$server_info_file" >> "$GITHUB_OUTPUT" + - name: Validate OpenAI API key input + if: ${{ inputs.prompt != '' || inputs['prompt-file'] != '' }} + shell: bash + run: | + openai_api_key="${{ inputs['openai-api-key'] }}" + if [ -z "${openai_api_key//[[:space:]]/}" ]; then + echo "openai-api-key input is empty. Set OPENAI_API_KEY secret and pass it to this action." >&2 + exit 1 + fi + - name: Check Responses API proxy status id: start_proxy if: ${{ inputs['openai-api-key'] != '' }} @@ -218,7 +228,7 @@ runs: # This step has an output named `port`. - name: Read server info id: read_server_info - if: ${{ inputs['openai-api-key'] != '' || inputs.prompt != '' || inputs['prompt-file'] != '' }} + if: ${{ inputs['openai-api-key'] != '' }} shell: bash run: node "${{ github.action_path }}/dist/main.js" read-server-info "${{ steps.derive_server_info.outputs.server_info_file }}"