Skip to content

Commit 02b005e

Browse files
committed
Fix CrossVendorAudit codex invocation: non-git PAI dirs and OpenAI env overrides
Two failure modes in invokeCodex(): 1. codex exec refuses to run when the working directory is not a git repository ('Not inside a trusted directory'), so the cross-vendor audit always returns skipped on installs that persist the PAI directory by means other than git. Pass --skip-git-repo-check. 2. The spawned codex process inherits the parent environment, and codex's auth precedence puts OPENAI_API_KEY / OPENAI_BASE_URL above ~/.codex/auth.json and config.toml. A stray key in the parent shell silently flips the audit from the user's configured codex auth (e.g. ChatGPT subscription) to direct API billing. Scrub both vars from the child env. Verified live on a non-git PAI install: audit runs end-to-end and persists a structured verdict where it previously logged 'skipped: codex exit 1'.
1 parent 2fde1bb commit 02b005e

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

Releases/v5.0.0/.claude/PAI/TOOLS/CrossVendorAudit.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,20 @@ function assembleBundle(isa: string, artifacts: string, toolTail: string, adviso
189189

190190
function invokeCodex(bundle: string): Promise<{ stdout: string; stderr: string; code: number | null }> {
191191
return new Promise((resolvePromise) => {
192+
// --skip-git-repo-check: the PAI directory is not always a git repository
193+
// (some installs persist it by other means), and codex exec refuses to run
194+
// from a non-git working directory without this flag.
195+
// Env scrub: codex's auth precedence puts OPENAI_API_KEY / OPENAI_BASE_URL
196+
// above ~/.codex/auth.json and config.toml, so a stray key in the parent
197+
// shell silently flips the audit from the user's configured codex auth
198+
// (e.g. ChatGPT subscription) to direct API billing.
199+
const env = { ...process.env };
200+
delete env.OPENAI_API_KEY;
201+
delete env.OPENAI_BASE_URL;
192202
const proc = spawn(
193203
CODEX_BIN,
194-
["exec", "--sandbox", "read-only", "--model", "gpt-5.4", "-"],
195-
{ stdio: ["pipe", "pipe", "pipe"] }
204+
["exec", "--sandbox", "read-only", "--skip-git-repo-check", "--model", "gpt-5.4", "-"],
205+
{ stdio: ["pipe", "pipe", "pipe"], env }
196206
);
197207
let stdout = "";
198208
let stderr = "";

0 commit comments

Comments
 (0)