fix: 修复资源不存在/已解散返回错误码及网关502问题

修复好友申请不存在时返回正确的 ErrNotFound 避免解引用 panic,新增通用函数判断群不存在或已解散并返回对应错误码,更新文档统一资源不存在类错误语义,避免服务端返回5xx错误。
This commit is contained in:
Austin
2026-09-29 13:34:24 +08:00
parent 1a8043bee2
commit cf9d559944
4 changed files with 53 additions and 2 deletions
+6 -2
View File
@@ -6899,8 +6899,12 @@ func (a *adapter) TenantFriendRequestResolve(id t.TenantID, requestID string, ac
defer cancel()
}
req, err := a.friendRequestByRequestID(ctx, id, requestID)
if err != nil || req == nil {
return req, err
if err != nil {
return nil, err
}
if req == nil {
// 好友申请不存在必须返回 ErrNotFound,否则上层拿到 (nil,nil) 会解引用 panic(网关 502)。
return nil, t.ErrNotFound
}
if req.TargetID != actor {
return nil, t.ErrPermissionDenied