fix(sdk): redact x-api-key in debug-log header dumps#3956
Conversation
The vendor template redacts Authorization/Cookie/Set-Cookie/api_key, which was correct for the petstore template (api_key with an underscore). When we changed the auth scheme to x-api-key in client.ts:authHeaders, the redaction list wasn't updated to match — so debug logs (logLevel: 'debug' or SUPERSET_LOG=debug) would emit the raw sk_live_… key. Bumps to 0.0.1-alpha.7.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe SDK version is bumped from Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 6/8 reviews remaining, refill in 13 minutes and 6 seconds.Comment |
Greptile SummaryThis PR fixes a credential-leak in the SDK's debug logger by adding Confidence Score: 5/5Safe to merge — minimal, targeted fix with no functional regressions. The change is a single-line addition to the redaction list that directly matches the header name used in No files require special attention.
|
| Filename | Overview |
|---|---|
| packages/sdk/src/internal/utils/log.ts | Adds x-api-key to the header redaction list in formatRequestDetails, closing the security gap where the actual auth header used by client.ts was not masked in debug logs. |
| packages/sdk/package.json | Version bump from 0.0.1-alpha.6 to 0.0.1-alpha.7 to publish the security fix. |
| packages/sdk/src/version.ts | Version constant updated to match package.json bump to 0.0.1-alpha.7. |
Sequence Diagram
sequenceDiagram
participant Caller
participant Client as client.ts
participant Logger as log.ts (formatRequestDetails)
participant Log as Debug Log
Caller->>Client: makeRequest(options)
Client->>Client: authHeaders() → { "x-api-key": "sk_live_..." }
Client->>Logger: formatRequestDetails({ headers })
Note over Logger: Redact sensitive headers:<br/>api_key, x-api-key ✅ (new),<br/>authorization, cookie, set-cookie
Logger-->>Client: headers with "x-api-key": "***"
Client->>Log: debug("request", { headers: { "x-api-key": "***" } })
Reviews (1): Last reviewed commit: "fix(sdk): redact x-api-key in debug-log ..." | Re-trigger Greptile
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
npm has alpha.6 as the most recent published; alpha.7 was bumped in 71bf008 but never `npm publish`-ed. Skip alpha.7 on the registry and ship the current repo state as alpha.8. Changes since alpha.6: - workspaces.create adopts the canonical host-service shape (#3893) - automations.list accepts --name filter (#3952) - automations.prompt split into automations.prompt.get / .set (#3959) - agents.list (presets demoted to UI-only configuration) (#4097) - agents.run / workspaces.create gain `superset-chat` agent + `kind` discriminator on launch results (terminal vs chat) (#4116) - type adjustments for v2 workspace render path (#4141) - redact x-api-key in debug-log header dumps (#3956, was alpha.7) After merge: `cd packages/sdk && bun run build && cd dist && npm publish --access public`.
Summary
The Stainless template's request-detail log redactor masks
Authorization,Cookie,Set-Cookie, andapi_key(underscore — petstore's auth header). When we shipped `@superset_sh/sdk` we changed the auth scheme in `client.ts:authHeaders` to use `x-api-key` (dash) for `sk_live_…` keys, but didn't update the redaction list to match.Net effect: any caller running with `logLevel: 'debug'` or `SUPERSET_LOG=debug` had their raw API key written into the debug logs alongside every request. Adding `x-api-key` to the redaction list patches it.
Bumps the SDK to `0.0.1-alpha.7`.
Test plan
Caught by greptile + cubic + coderabbit on #3937, follow-up since that PR was already merged.
Summary by cubic
Redacts the
x-api-keyheader in SDK debug request logs to prevent API key leakage when debug logging is enabled. Bumps@superset/sdkto0.0.1-alpha.7.Written for commit caa3c0f. Summary will update on new commits.
Summary by CodeRabbit
Chores
Bug Fixes