Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #308

Merged
merged 5 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.12.15
1.12.16
2 changes: 2 additions & 0 deletions pkg/database/dao/subject_template_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ func (m *subjectTemplateGroupManager) GetMaxExpiredAtBySubjectGroup(
return expiredAt.Int64, nil
}

// FIXME (nan): 使用 Max 聚合 SQL 且对 NULL 返回了 nil, 所以不存在 sql.ErrNoRows 的情况,
// 但上层调用点却使用了 sql.ErrNoRows 判断后进行各种逻辑处理,需要 Review 后决策如何修复
// Handle NULL case, for example, by returning a default value
return 0, nil
}
Expand Down
8 changes: 7 additions & 1 deletion pkg/task/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,13 @@ func (h *groupAlterMessageHandler) alterSubjectActionGroupResource(subjectPK, ac
subjectPK, groupPK,
)
}
found := !errors.Is(err, service.ErrGroupMemberNotFound)
// Note:
// 由于 groupService.GetMaxExpiredAtBySubjectGroup 函数里的
// subjectTemplateGroupManager.GetMaxExpiredAtBySubjectGroup 使用 Max 聚合 SQL 且对 NULL 返回了 nil
// 所以导致 不可能存在 sql.ErrNoRows 的情况,即 ErrGroupMemberNotFound 也不可能出现
// 临时解决方案:由于 用户与用户组关系存在时 expiredAt 一定不为空,所以这里判断 expiredAt != 0 来表示用户还在用户组里
// FIXME (nan): 待底层 GetMaxExpiredAtBySubjectGroup 修复后,这里也对应进行修复
found := !errors.Is(err, service.ErrGroupMemberNotFound) && expiredAt != 0

// 查询group action授权资源实例
resourceMap, err := cacheimpls.GetGroupActionAuthorizedResource(
Expand Down
4 changes: 4 additions & 0 deletions release.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.12.16

- bugfix: fix the issue where relationships that have been deleted were not cleaned up in the subject_action_group_resource table due to incorrect queries on the maximum expiration time for users and groups

# 1.12.15

- add: query subject group details api
Expand Down
Loading