refactor: migrate update API calls from PUT to PATCH#2910
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 refactors the application's API interaction layer to improve consistency and adherence to RESTful principles. By transitioning update operations from Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
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. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request effectively refactors the API calls by migrating update operations from PUT to PATCH requests, aligning with RESTful best practices for partial updates. It also removes the now obsolete client.put method. Furthermore, several asynchronous functions that did not utilize await internally have been refactled to return Promises directly, improving code conciseness and efficiency. The changes are well-executed and enhance the codebase's maintainability and adherence to modern TypeScript patterns.
|
Clean, focused refactor. The PUT→PATCH migration is consistent across all update endpoints, and removing redundant Two issues worth addressing: (1) |
There was a problem hiding this comment.
Pull request overview
Migrates the GUI API layer to align with the updated API spec semantics by switching update operations from PUT to PATCH, and refactors several API wrappers to remove redundant async/await.
Changes:
- Add
client.patch()and removeclient.put()from the shared API client. - Switch user/project/asset/course/course-series update calls to use
PATCH. - Refactor various API wrapper functions to return Promises directly instead of using
async/await.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| spx-gui/src/apis/common/client.ts | Replace put() with patch() on the shared client. |
| spx-gui/src/apis/user.ts | Switch signed-in user update to PATCH; remove redundant async/await in wrappers. |
| spx-gui/src/apis/project.ts | Switch project update to PATCH; remove redundant async/await in wrappers. |
| spx-gui/src/apis/asset.ts | Switch asset update to PATCH. |
| spx-gui/src/apis/course.ts | Switch course update to PATCH; remove redundant async/await in wrappers. |
| spx-gui/src/apis/course-series.ts | Switch course-series update to PATCH; remove redundant async/await in wrappers. |
| spx-gui/src/apis/util.ts | Refactor makeObjectUrls wrapper to be non-async. |
| spx-gui/src/apis/sb2xbp.ts | Refactor Scratch conversion wrapper to be non-async. |
| spx-gui/src/apis/copilot.ts | Refactor generateMessage wrapper to return the Promise directly. |
| spx-gui/src/apis/aigc.ts | Refactor several wrappers to return Promises directly. |
Comments suppressed due to low confidence (1)
spx-gui/src/apis/sb2xbp.ts:19
convertScratchToXbpno longer usesasync, so the file size guard now throws synchronously instead of returning a rejected Promise. This is a behavioral change for callers that pass the result into utilities expecting a Promise (e.g.withLoading(promise, ...)) and can also change how errors are surfaced/handled. Consider keepingasynchere, or return a rejected Promise for oversize files to preserve Promise-based error semantics.
export function convertScratchToXbp(file: File, signal?: AbortSignal) {
if (file.size > maxFileSize) {
const maxFileSizeHumanized = humanizeFileSize(maxFileSize)
throw new DefaultException({
en: `File size exceeds limit (max ${maxFileSizeHumanized.en})`,
zh: `文件尺寸超限(最大 ${maxFileSizeHumanized.zh})`
})
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
- Add `client.patch` and remove obsolete `client.put` - Update user, project, asset, course, and course-series update calls Updates goplus#2892 Signed-off-by: Aofei Sheng <aofei@aofeisheng.com>
client.patchand remove obsoleteclient.putUpdates #2892