Skip to content

fix: mask API key output and clear conflicting OAuth credentials#195

Merged
NianJiuZst merged 1 commit into
mainfrom
codex/mask-api-key-config
Jul 15, 2026
Merged

fix: mask API key output and clear conflicting OAuth credentials#195
NianJiuZst merged 1 commit into
mainfrom
codex/mask-api-key-config

Conversation

@NianJiuZst

@NianJiuZst NianJiuZst commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • mask api_key in normal and dry-run config set output
  • remove an existing OAuth block when a new API key is stored
  • clear the cached region so the new key is detected against the correct host
  • reject empty or whitespace-only API keys before reading or writing configuration
  • keep config command tests isolated so they do not replace the loader for auth tests

Root cause

config set rendered every value verbatim, including API keys. It also wrote a new api_key without clearing OAuth, while the credential resolver prefers OAuth over the config-file API key. The command could therefore leak the secret and then silently continue using the old credential.

The first regression tests used a process-wide Bun module mock. After PR #194 added auth persistence coverage, that mock leaked into the auth tests and replaced their real temporary config loader. Empty values also remained valid and could erase a working OAuth session while saving an unusable key.

Impact

The complete key is still written to the mode-0600 config file, but terminal and CI output only receive a masked value. A successful API-key update now leaves one unambiguous credential source. Empty values fail without touching existing credentials, and the tests preserve the isolation introduced by PR #194.

Validation

  • bun test — 392 passed
  • targeted config and auth tests — 18 passed
  • bun run typecheck
  • bun run build:dev
  • ESLint on all changed TypeScript files
  • git diff --check

@NianJiuZst NianJiuZst marked this pull request as ready for review July 15, 2026 05:50
@NianJiuZst NianJiuZst force-pushed the codex/mask-api-key-config branch from adec0dc to dc9b7e2 Compare July 15, 2026 05:56
@NianJiuZst NianJiuZst merged commit 9014266 into main Jul 15, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant