Summary
portkey verify, portkey status, and portkey discover fail to parse x-portkey-config / x-portkey-provider out of ANTHROPIC_CUSTOM_HEADERS when the header uses the conventional Name: value form (space after the colon). The regexes require the value to start immediately after the colon, so the match returns undefined, the code falls back to "", and verify sends an empty routing header — the gateway then rejects the request even though the user's Claude Code setup works fine.
Environment
- portkey CLI v1.1.0 (npm, global install), Node 26, macOS
- Self-hosted gateway, routing via a Portkey config ID
Reproduction
export ANTHROPIC_AUTH_TOKEN=<key>
export ANTHROPIC_CUSTOM_HEADERS="x-portkey-config: pc-xxxxx" # note the space — how Claude Code docs/tooling commonly format headers
portkey verify
Output:
→ Routing via config: <-- empty value, silently
◇ HTTP 400 (231ms)
{"status":"failure","message":"Either x-portkey-config or x-portkey-provider header is required"}
Removing the space (x-portkey-config:pc-xxxxx) makes the same command succeed. Claude Code itself parses ANTHROPIC_CUSTOM_HEADERS fine with the space, so a working setup reports as broken.
Root cause
Every parse site uses /(x-portkey-config|x-portkey-provider):(\S+)/-style regexes with no optional whitespace after the colon. In v1.1.0 there are 8 occurrences across 4 files:
src/commands/claude-code/verify.js lines 197, 201
src/commands/claude-code/discover.js lines 274, 277
src/commands/claude-code/status.js lines 118, 121
src/utils.js lines 400, 402
The failure is worsened by the ?.[1] || "" fallback: includes("x-portkey-config:") is true, so the config branch is taken, but the capture is empty — verify proceeds and sends x-portkey-config: "" instead of erroring, and status/discover report an empty config.
Suggested fix
Allow optional whitespace after the colon at all 8 sites, e.g.:
customHeaders.match(/x-portkey-config:\s*(\S+)/)?.[1] || ""
and ideally treat a matched-but-empty value as "not found" rather than sending an empty header.
Summary
portkey verify,portkey status, andportkey discoverfail to parsex-portkey-config/x-portkey-providerout ofANTHROPIC_CUSTOM_HEADERSwhen the header uses the conventionalName: valueform (space after the colon). The regexes require the value to start immediately after the colon, so the match returnsundefined, the code falls back to"", andverifysends an empty routing header — the gateway then rejects the request even though the user's Claude Code setup works fine.Environment
Reproduction
Output:
Removing the space (
x-portkey-config:pc-xxxxx) makes the same command succeed. Claude Code itself parsesANTHROPIC_CUSTOM_HEADERSfine with the space, so a working setup reports as broken.Root cause
Every parse site uses
/(x-portkey-config|x-portkey-provider):(\S+)/-style regexes with no optional whitespace after the colon. In v1.1.0 there are 8 occurrences across 4 files:src/commands/claude-code/verify.jslines 197, 201src/commands/claude-code/discover.jslines 274, 277src/commands/claude-code/status.jslines 118, 121src/utils.jslines 400, 402The failure is worsened by the
?.[1] || ""fallback:includes("x-portkey-config:")is true, so the config branch is taken, but the capture is empty —verifyproceeds and sendsx-portkey-config: ""instead of erroring, andstatus/discoverreport an empty config.Suggested fix
Allow optional whitespace after the colon at all 8 sites, e.g.:
and ideally treat a matched-but-empty value as "not found" rather than sending an empty header.