fix(cli): preserve Request headers in DevTools activity logger#26078
fix(cli): preserve Request headers in DevTools activity logger#26078
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a bug in the DevTools fetch interceptor where request metadata was being lost when a Request object was used as the primary argument. By ensuring that methods and headers are correctly merged from both the Request object and the init parameter, the fix restores compatibility with libraries like ky that rely on this pattern, specifically resolving authentication issues with private npm registries. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request updates the ActivityLogger to support Request objects in fetch calls, ensuring methods and headers are correctly captured. A new test case validates this functionality. Review feedback points out that the current header merging logic violates the Fetch API specification, which requires init.headers to replace input.headers. Improvements were also suggested to use object spread and nullish coalescing for better code consistency.
|
Size Change: +237 B (0%) Total Size: 33.9 MB
ℹ️ View Unchanged
|
…-after-nits, google-gemini/gemini-cli#26078 merge-after-nits
Summary
This PR fixes a bug in the DevTools fetch interceptor (
ActivityLogger.patchGlobalFetch) where headers, methods, and bodies were being stripped when provided via aRequestobject (the first argument tofetch) instead of theinitargument. This specifically caused issues with update checks (usingky) when private npm registries required authentication, leading to 403 errors.Details
The interceptor was assuming that all request metadata resided in the
initparameter. When libraries likekypass aRequestobject with headers (e.g.,Authorization) and an emptyinitobject, the interceptor would create a newHeadersobject from the emptyinit, add thex-activity-request-id, and pass that to the originalfetch, effectively overriding and losing the original headers on theRequestobject.This fix:
Requestobject if not ininit.Requestobject andinit.Requestobject's body ifinit.bodyis missing.Related Issues
Fixes #23481
How to Validate
npm test -w @google/gemini-cli -- src/utils/activityLogger.test.ts"general": { "devtools": true }.fetchcall passing aRequestobject with custom headers and an emptyinitobject.Pre-Merge Checklist