fix(server): add missing return after error responses#2150
Open
Lanfei wants to merge 1 commit intoOpenListTeam:mainfrom
Open
fix(server): add missing return after error responses#2150Lanfei wants to merge 1 commit intoOpenListTeam:mainfrom
Lanfei wants to merge 1 commit intoOpenListTeam:mainfrom
Conversation
In BeginAuthnRegistration (webauthn.go), missing return statements after error responses caused the function to continue executing with a nil authnInstance, potentially leading to a nil pointer panic. In OIDCLoginCallback and SSOLoginCallback (ssologin.go), missing return statements after GenerateToken/autoRegister errors caused the handler to send a second response, resulting in a superfluous response write. In SetThunderBrowser (offline_download.go), the default case of the storage type switch sent an error response but did not return, causing SaveSettingItems and tool initialization to continue executing even when driver type validation failed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
12ae7bf to
11281cf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description / 描述
Add missing
returnstatements after error responses in several HTTP handlers to prevent code from continuing to execute after an error has been sent to the client.在多个 HTTP 处理函数中,错误响应后添加缺失的
return语句,以防止在向客户端发送错误后代码继续执行。server/handles/offline_download.go:SetThunderBrowser— addreturnafter unsupported driver error / 不支持的驱动错误后添加returnserver/handles/ssologin.go:OIDCLoginCallback,SSOLoginCallback— addreturnafter error responses / 错误响应后添加returnserver/handles/webauthn.go:BeginAuthnRegistration— addreturnafter error responses / 错误响应后添加returnMotivation and Context / 背景
Without
returnaftercommon.ErrorResp/common.ErrorStrResp, the handler continues executing after writing an error response to the client. This can cause unexpectedbehavior such as writing multiple responses, using nil/invalid values from failed operations, or triggering redirects after an error response has already been sent.
在调用
common.ErrorResp/common.ErrorStrResp后缺少return语句,会导致处理函数在向客户端写入错误响应后继续执行。这可能引发意外行为,如多次写入响应、使用失败操作产生的空值/无效值,或在错误响应已发送后仍触发重定向。
How Has This Been Tested? / 测试
Manually triggered the affected error paths (unsupported driver, OIDC/SSO login failures, WebAuthn registration failures) and verified that execution stops after the error
response.
手动触发上述错误路径(不支持的驱动、OIDC/SSO 登录失败、WebAuthn 注册失败),确认在错误响应后执行正常终止。
Checklist / 检查清单
我已阅读 CONTRIBUTING 文档。
go fmtor prettier.我已使用
go fmt或 prettier 格式化提交的代码。我已为此 PR 添加了适当的标签(如无权限或需要的标签不存在,请在描述中说明,管理员将后续处理)。
我已在适当情况下使用"Request review"功能请求相关代码作者进行审查。
我已相应更新了相关仓库(若适用)。