Skip to content

fix(server): add missing return after error responses#2150

Open
Lanfei wants to merge 1 commit intoOpenListTeam:mainfrom
Lanfei:fix/missing-return-after-error
Open

fix(server): add missing return after error responses#2150
Lanfei wants to merge 1 commit intoOpenListTeam:mainfrom
Lanfei:fix/missing-return-after-error

Conversation

@Lanfei
Copy link
Contributor

@Lanfei Lanfei commented Feb 19, 2026

Description / 描述

Add missing return statements 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 — add return after unsupported driver error / 不支持的驱动错误后添加 return
  • server/handles/ssologin.go: OIDCLoginCallback, SSOLoginCallback — add return after error responses / 错误响应后添加 return
  • server/handles/webauthn.go: BeginAuthnRegistration — add return after error responses / 错误响应后添加 return

Motivation and Context / 背景

Without return after common.ErrorResp / common.ErrorStrResp, the handler continues executing after writing an error response to the client. This can cause unexpected
behavior 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 / 检查清单

  • I have read the CONTRIBUTING document.
    我已阅读 CONTRIBUTING 文档。
  • I have formatted my code with go fmt or prettier.
    我已使用 go fmtprettier 格式化提交的代码。
  • I have added appropriate labels to this PR (or mentioned needed labels in the description if lacking permissions).
    我已为此 PR 添加了适当的标签(如无权限或需要的标签不存在,请在描述中说明,管理员将后续处理)。
  • I have requested review from relevant code authors using the "Request review" feature when applicable.
    我已在适当情况下使用"Request review"功能请求相关代码作者进行审查。
  • I have updated the repository accordingly (If it's needed).
    我已相应更新了相关仓库(若适用)。

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>
@Lanfei Lanfei force-pushed the fix/missing-return-after-error branch from 12ae7bf to 11281cf Compare February 19, 2026 15:53
@Lanfei Lanfei changed the title fix: add missing return after error responses fix(server): add missing return after error responses Feb 19, 2026
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.

1 participant

Comments