fix(cli): use shell-neutral guidance for overriding API key variables - #216
Open
rohanpoudel2 wants to merge 2 commits into
Open
fix(cli): use shell-neutral guidance for overriding API key variables#216rohanpoudel2 wants to merge 2 commits into
rohanpoudel2 wants to merge 2 commits into
Conversation
`codex-security login status` and `codex-security login` printed
POSIX-only `unset OPENAI_API_KEY CODEX_API_KEY` guidance when an
environment API key overrides (or would override) a stored ChatGPT
sign-in. `unset` is not a valid PowerShell command, so Windows users
received advice they could not act on.
Both call sites now describe the fix in shell-neutral terms ("remove
... from the environment, then run the command again") instead of
naming a POSIX shell built-in. The dynamic variant, which lists
whichever of OPENAI_API_KEY/CODEX_API_KEY are actually set, still
reads naturally for one or two variables.
Fixes openai#33
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #33
Problem
When an API-key environment variable overrides a stored ChatGPT sign-in, the CLI suggests
unset, which PowerShell does not provide. Windows users are told to run a command that does not exist, precisely when they are trying to resolve credential precedence.There are two call sites in
src/cli.ts, both reported in #33:login status, which always names both variables:the
loginwarning that a configured environment API key will keep taking precedence, which names only the variables actually set:Change
Both messages now use shell-neutral wording, following the direction suggested in the issue:
The second message builds its variable list at runtime and can name either one or both variables, so the separator changed from
" "to" and ". That set has at most two members, so this reads correctly in both cases without needing a general list formatter. Variable-name casing is passed through unchanged, as before.Verification
tests-ts/cli-authentication.test.tsare updated.uses shell-neutral guidance when an API key overrides the stored login, asserts that stderr fromlogin statusand fromlogin(with one and with two variables set) never matches/\bunset\b/,/\bexport\s+\w+=/, or/\$env:/i, so this cannot silently regress into any single-shell dialect.pnpm run typesandpnpm run formatare clean.Left alone deliberately
src/api.tsalready spells out both POSIX and PowerShell ($env:) forms, so it needs no change.#!/bin/shwrapper the CLI generates is a real POSIX script, not user-facing shell advice.README.mdandsdk/typescript/README.mdshowunset OPENAI_API_KEY CODEX_API_KEYinside an explicitly labelledbashfence. A labelled shell example is not the same defect as the CLI assuming a shell, so it is out of scope here; happy to follow up if you would like the docs to show both shells.