Skip to content

Conversation

@lieyan666
Copy link

@lieyan666 lieyan666 commented Jan 23, 2026

问题描述

修复 #1082

当所有 Antigravity 账号都不可用时,CPA 之前返回 HTTP 400,但这会被 NewAPI 识别为请求错误而不进行重试,影响整体可靠性。

修改内容

sdk/api/handlers/handlers.gogetRequestDetails 函数的错误响应状态码从 http.StatusBadRequest (400) 修改为 http.StatusBadGateway (502)。

效果

HTTP 502 属于服务端错误,会触发 NewAPI 的错误重试机制,从而提高整体可靠性。

Problem Description

Fixes #1082

When all Antigravity accounts are unavailable, CPA previously returned HTTP 400. However, this status code is interpreted by NewAPI as a client request error, which prevents retry attempts and impacts overall system reliability.

Changes Made

Modified the error response status code in the getRequestDetails function within
sdk/api/handlers/handlers.go
from http.StatusBadRequest (400) to http.StatusBadGateway (502).

Impact

HTTP 502 is categorized as a server-side error, which triggers NewAPI's error retry mechanism, thereby improving overall system reliability.

Fixes router-for-me#1082

When all Antigravity accounts are unavailable, the error response now returns
HTTP 502 (Bad Gateway) instead of HTTP 400 (Bad Request). This ensures that
NewAPI and other clients will retry the request on a different channel,
improving overall reliability.
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @lieyan666, 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!

此拉取请求旨在通过调整错误响应状态码来提高系统可靠性。之前,当没有可用的 Antigravity 账号时,系统返回 400 状态码,这导致 NewAPI 不会触发重试机制。通过将状态码更改为 502,NewAPI 现在能够识别这是一个服务端错误并进行重试,从而确保在临时性提供商不可用时请求能够得到更稳健的处理。

Highlights

  • 错误码修复: 当所有 Antigravity 账号都不可用时,将返回的 HTTP 状态码从 400 (BadRequest) 修改为 502 (BadGateway)。

🧠 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.

Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

本次 PR 将在没有可用 provider 时返回的 HTTP 状态码从 400 修改为 502,目的是为了让客户端能够进行重试,从而提高系统的整体可靠性。这个修改符合 PR 的目标。我有一个小建议,可以使错误信息与新的 5xx 状态码的含义更加一致,以提高清晰度。


if len(providers) == 0 {
return nil, "", &interfaces.ErrorMessage{StatusCode: http.StatusBadRequest, Error: fmt.Errorf("unknown provider for model %s", modelName)}
return nil, "", &interfaces.ErrorMessage{StatusCode: http.StatusBadGateway, Error: fmt.Errorf("unknown provider for model %s", modelName)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

将状态码更改为 http.StatusBadGateway (502) 以触发客户端重试是合理的。然而,当前的错误信息 unknown provider for model %s 更像是在描述一个永久性的配置问题(对应 4xx 错误),而不是一个临时性的服务问题(对应 5xx 错误)。

为了使错误信息与 5xx 状态码的意图(即可重试的临时故障)更加一致,建议将错误信息修改为更能反映临时性的描述,例如:no provider is currently available for model %s

Suggested change
return nil, "", &interfaces.ErrorMessage{StatusCode: http.StatusBadGateway, Error: fmt.Errorf("unknown provider for model %s", modelName)}
return nil, "", &interfaces.ErrorMessage{StatusCode: http.StatusBadGateway, Error: fmt.Errorf("no provider is currently available for model %s", modelName)}

@lieyan666
Copy link
Author

@luispater @hkfires 两位大佬好,麻烦有空帮忙Review一下,这个PR仅仅修改了一个HTTP状态码,如果没问题的话求合并,感谢!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

修改报错HTTP Status Code

1 participant