fix(group): 管理员清空分组描述时正确持久化#3035
Merged
Wei-Shaw merged 1 commit intoJun 5, 2026
Merged
Conversation
Contributor
|
All contributors have signed the CLA. ✅ |
UpdateGroup 之前用 `if input.Description != ""` 判空, 把"未提供"和"显式置空"混为一谈,导致管理员在分组编辑表单 里清空备注后保存无效。 将 UpdateGroupRequest / UpdateGroupInput 的 Description 改为 *string:nil 表示未提供(保持原值),"" 表示显式清空。
e5c9216 to
bc7ce18
Compare
Contributor
Author
This failure is unrelated to the diff in this PR. It's
Evidence this is pre-existing on
The fix is to bump the CI Go toolchain to |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
UpdateGroupRequest/UpdateGroupInput的Description字段改为*string,区分「未提供」和「显式置空」nil(请求未带description字段或为null)→ 保持原值,与旧行为一致""(请求显式传空串)→ 清空描述,修复前会被静默忽略Why
backend/internal/service/admin_service.go原来用if input.Description != ""判空,导致分组备注一旦写入就再也无法在 UI 上清掉(例如simple_mode_default_groups.go自动写入的Auto-created default group留痕)。Test plan
go test -tags=unit -run TestAdminService_UpdateGroup ./internal/service/全部通过TestAdminService_UpdateGroup_ClearsDescriptionWhenEmptyString校验显式清空生效TestAdminService_UpdateGroup_PreservesDescriptionWhenNil校验未提供时不动原值go build ./...通过