Skip to content

verify/status/discover: x-portkey-config not parsed when ANTHROPIC_CUSTOM_HEADERS has a space after the colon #12

Description

@diegoimbus

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions