fix(ai): keep provider headers redacted#6548
Conversation
🦋 Changeset detectedLatest commit: 0fa4795 The changes in this PR will be included in the next version bump. This PR includes changesets to release 27 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
📝 WalkthroughWalkthroughOpenAI and OpenAI-compatible clients now apply provider-specific header redaction during HTTP request execution, including transformed clients. Error-mapping tests verify authorization, organization, and project headers are redacted. ChangesOpenAI header redaction
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/ai/openai/src/OpenAiClient.ts (1)
290-306: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick winApply redaction to the socket streaming path too.
Line 293 returns
OpenAiSocket.createResponseStreambeforewithRedactedOpenAiHeadersis applied. Socket-generatedNetworkErrorcontexts retainrequest.headers, so organization/project values can leak when socket mode is enabled. Wrap the entire socket/non-socket dispatch (and socket stream execution as needed) in the redaction context.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/ai/openai/src/OpenAiClient.ts` around lines 290 - 306, The createResponseStream socket branch bypasses withRedactedOpenAiHeaders, allowing sensitive request headers to remain in socket-generated NetworkError contexts. Update createResponseStream so the entire socket/non-socket dispatch is executed within the withRedactedOpenAiHeaders redaction context, preserving the existing socket delegation and HTTP client error mapping.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@packages/ai/openai/src/OpenAiClient.ts`:
- Around line 290-306: The createResponseStream socket branch bypasses
withRedactedOpenAiHeaders, allowing sensitive request headers to remain in
socket-generated NetworkError contexts. Update createResponseStream so the
entire socket/non-socket dispatch is executed within the
withRedactedOpenAiHeaders redaction context, preserving the existing socket
delegation and HTTP client error mapping.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 3f41532f-2191-4f77-930e-c0213d021162
📒 Files selected for processing (6)
.changeset/fix-ai-redacted-provider-headers.mdpackages/ai/openai-compat/src/OpenAiClient.tspackages/ai/openai-compat/test/OpenAiClient.test.tspackages/ai/openai/src/OpenAiClient.tspackages/ai/openai/src/OpenAiClientGenerated.tspackages/ai/openai/test/OpenAiClient.test.ts
Fixes #6525
Summary
Tests
Summary by CodeRabbit