feat: always add API key to endpoint requests#57
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughThe PR changes client request authentication to include API/auth headers by default unless Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/client.ts (1)
89-97:⚠️ Potential issue | 🟠 Major
getContext()still permits unauthenticated requests via forwarded options.Because
optionsis spread directly, callers can passauth: falseand bypass headers for context GET. If the intended contract is always-auth forgetContext(), ignore or stripauthhere.🔧 Suggested hardening for `getContext()`
getContext(options?: Partial<ClientRequestOptions>) { + const { auth: _auth, method: _method, path: _path, query: _query, ...rest } = options ?? {}; return this.get({ - ...options, + ...rest, path: "/context", query: { application: this._opts.application.name, environment: this._opts.environment, }, }); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/client.ts` around lines 89 - 97, getContext currently forwards caller-supplied options which allows bypassing authentication by passing auth: false; update getContext (in src/client.ts) so it always enforces authentication by overriding/stripping any auth flag from the merged options (e.g., explicitly set auth: true or delete auth before calling this.get), ensuring the request to path "/context" uses the client's intended auth headers regardless of the passed Partial<ClientRequestOptions>.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/client.ts`:
- Around line 24-25: Update the docstring for ClientRequestOptions.auth to
reflect runtime behavior by changing the wording from "The API key is now always
sent. This option will be removed in a future version." to something like "The
API key is sent by default; this option can be used to suppress it." Also ensure
the comment mentions it's deprecated if still intended, and keep the runtime
behavior in code (see ClientRequestOptions.auth and the header-suppression
branch around the auth check at line where auth: false is handled) consistent
with the new wording so users aren't misled.
---
Outside diff comments:
In `@src/client.ts`:
- Around line 89-97: getContext currently forwards caller-supplied options which
allows bypassing authentication by passing auth: false; update getContext (in
src/client.ts) so it always enforces authentication by overriding/stripping any
auth flag from the merged options (e.g., explicitly set auth: true or delete
auth before calling this.get), ensuring the request to path "/context" uses the
client's intended auth headers regardless of the passed
Partial<ClientRequestOptions>.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e6f50be8-96f9-464b-a9a2-e64654edc8f8
📒 Files selected for processing (2)
src/__tests__/client.test.jssrc/client.ts
62db72a to
cabcd9c
Compare
This PR deprecates the
authflag in theClientRequestOptionstype, and updates the contextGETrequest to always send the auth headers with it.Summary by CodeRabbit
Refactor
Tests