Skip to content

Claude Code. Any Model. The most powerful AI coding agent now speaks every language.

fix: redact key-shaped text from a credential failure line

Jack Rudenko0c5920f5d60f
diff --git a/ai-docs/reports/BACKEND_zero_prices_models_index-20260921.md b/ai-docs/reports/BACKEND_zero_prices_models_index-20260921.md
index 1ebaae28..0da9b5aa 100644
--- a/ai-docs/reports/BACKEND_zero_prices_models_index-20260921.md
+++ b/ai-docs/reports/BACKEND_zero_prices_models_index-20260921.md
@@ -53,6 +53,29 @@ both sides is rejected. We would rather delete that rule than keep it — it is
data, which is exactly what both sides agreed to avoid — so it goes as soon as the rows say
`unavailable`.
+## A short list of first-party models that may be missing their vendor's own route
+
+Low priority, and we checked carefully before sending it, because our first pass at this was
+wrong. Counting raw totals suggested your own-API coverage was badly incomplete (deepseek 2 of 34,
+qwen 136 of 240). It is not. Vendors expose only current models on their own APIs, and once retired
+generations, open-weight releases, gateway quantizations (`-fp8`, `-fp4`, `-lora`), provider-suffixed
+variants (`-di`, `-n`, `-el`, `-fw`) and route variants (`kimi-k3-256k`) are excluded, your coverage
+matches what the vendors actually host. DeepSeek publishing only `deepseek-v4.1-flash` and
+`deepseek-v4-pro` on `deepseek/direct-api` is correct; z-ai's 11 and MiniMax's 8 are their current
+lineups.
+
+What is left after that filter is a handful we believe the vendor does host:
+
+| Model | Expected route | Note |
+|---|---|---|
+| `glm-4.5v`, `glm-4.6v`, `glm-5v-turbo` | `z-ai/direct-api` | Z.ai's own API serves its vision models |
+| `glm-4.7-flash` | `z-ai/direct-api` | the rest of the 4.7 line is mapped |
+| `kimi-k2-0905` | `moonshotai/direct-api` | |
+| `minimax-m2-her`, `minimax-m1` | `minimax/direct-api` | |
+
+Each may have a reason we cannot see — a retirement, a region, a different endpoint. Treat the list
+as a question rather than a defect report.
+
## Nothing else outstanding from our side
The two design answers we sent still stand: unknown modalities as an absent field are right for
diff --git a/packages/cli/src/auth/credentials/types.ts b/packages/cli/src/auth/credentials/types.ts
index b48cb4f1..e1908caa 100644
--- a/packages/cli/src/auth/credentials/types.ts
+++ b/packages/cli/src/auth/credentials/types.ts
@@ -61,15 +61,51 @@ export interface ReadinessResult {
* can be a multi-line Rust struct dump, and pasting one into a routing warning
* buries the sentence that matters.
*
- * Message text only. A credential source never puts key material in an error
- * message, and this does not go looking for any.
+ * Message text only, and redacted — see {@link redactSecrets}. claudish's own
+ * credential sources never put key material in an error message, but this line
+ * is not always ours: it can be an SDK's, a shell tool's, or an upstream
+ * server's, and those quote what they were given.
*/
export function readinessDetail(err: unknown): string | undefined {
- const line = (err instanceof Error ? err.message : String(err ?? "")).split("\n")[0].trim();
- if (!line) return undefined;
+ const raw = (err instanceof Error ? err.message : String(err ?? "")).split("\n")[0].trim();
+ if (!raw) return undefined;
+ const line = redactSecrets(raw);
return line.length > 200 ? `${line.slice(0, 199)}…` : line;
}
+/**
+ * Remove anything key-shaped from a line that is about to be shown or logged.
+ *
+ * Defence in depth, for the case where the text is not ours. The concrete
+ * vector is a URL: Google's endpoints take the key as a QUERY PARAMETER, so any
+ * error that quotes the request URL — a fetch failure, a 400 body, a curl-style
+ * diagnostic from a shell tool — carries the key inside an otherwise ordinary
+ * sentence. An `Authorization` header echoed into an error body does the same.
+ *
+ * Deliberately narrow. It targets the shapes a secret actually takes, rather
+ * than masking every long token, because over-redacting destroys the part of
+ * the message a user needs: a redacted request id or model name turns a
+ * diagnosable failure into "something went wrong".
+ */
+export function redactSecrets(text: string): string {
+ return (
+ text
+ // `?key=…`, `&api_key=…`, `token=…`, `secret=…`, `password=…`
+ .replace(
+ /([?&](?:api[-_]?key|key|access[-_]?token|token|secret|password)=)[^&\s"']+/gi,
+ "$1[redacted]"
+ )
+ // `Authorization: Bearer …`, and a bare `Bearer …`
+ .replace(/(bearer\s+)[A-Za-z0-9._~+/=-]{8,}/gi, "$1[redacted]")
+ // Vendor-prefixed keys, which are self-identifying: sk-…, sk_live_…, AIza…,
+ // ghp_…, xoxb-…. The prefix is kept so the reader can see WHICH credential.
+ .replace(/\b(sk|rk|pk)[-_][A-Za-z0-9_-]{12,}/g, "$1-[redacted]")
+ .replace(/\bAIza[A-Za-z0-9_-]{10,}/g, "AIza[redacted]")
+ .replace(/\b(gh[pousr]_)[A-Za-z0-9]{16,}/g, "$1[redacted]")
+ .replace(/\b(xox[abposr]-)[A-Za-z0-9-]{10,}/g, "$1[redacted]")
+ );
+}
+
export interface RequestAuthContext {
model: string;
forceRefresh?: boolean;