fix(cli): make extension release downloads failure-atomic - #28656
fix(cli): make extension release downloads failure-atomic#28656GautamSharma99 wants to merge 2 commits into
Conversation
|
📊 PR Size: size/L
|
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 refactors the extension download process in the CLI to be failure-atomic. By downloading to a temporary file and utilizing the Node.js pipeline utility, the system now guarantees that incomplete or corrupted archives are not left behind if a download fails. The changes improve the reliability of the CLI by ensuring that network or filesystem interruptions result in a clean state, and they include robust regression tests to verify these failure modes. 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 the 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 counterproductive. 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 refactors the downloadFile function to use a temporary file path (.downloading) during download, ensuring incomplete files are cleaned up on failure, and updates the stream handling using pipeline. It also adds comprehensive unit tests for various stream and request error scenarios. The review feedback correctly identifies a high-severity security vulnerability where the sensitive GitHub Authorization token is forwarded during HTTP redirects to potentially untrusted domains, and provides a clear remediation to strip the header when redirecting to a different host.
Summary
Make GitHub-release extension downloads failure-atomic so request, response-stream, and filesystem failures reject cleanly without crashing the CLI or leaving a partial archive at the extraction path.
Previously,
downloadFile()piped the HTTP response directly to the final destination and listened only forfinish. Errors emitted after headers arrived or by the destination stream had no coordinated handler, allowing unhandlederrorevents, hung installs, and incomplete archives.Details
<destination>.downloadingfile instead of the final archive path.node:stream/promises.pipeline()so backpressure, stream errors, closure, and teardown are handled together.Authorizationheader before following a cross-origin redirect, including protocol or port changes.The tests now use real
PassThroughstream behavior and add regressions for:Related Issues
Fixes #28645
How to Validate
npm test --workspace @google/gemini-cli -- src/config/extensions/github.test.ts npm run typecheck --workspace @google/gemini-cli npx eslint packages/cli/src/config/extensions/github.ts packages/cli/src/config/extensions/github.test.ts npx prettier --check packages/cli/src/config/extensions/github.ts packages/cli/src/config/extensions/github.test.ts npm run pre-commitExpected results:
.downloadinguntil atomic publication.Pre-Merge Checklist