Skip to content

fix(group): 管理员清空分组描述时正确持久化#3035

Merged
Wei-Shaw merged 1 commit into
Wei-Shaw:mainfrom
ghostg00:fix/admin-group-clear-description
Jun 5, 2026
Merged

fix(group): 管理员清空分组描述时正确持久化#3035
Wei-Shaw merged 1 commit into
Wei-Shaw:mainfrom
ghostg00:fix/admin-group-clear-description

Conversation

@ghostg00

@ghostg00 ghostg00 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • 修复管理员在「分组管理 → 编辑」中清空备注后保存无效的问题
  • UpdateGroupRequest / UpdateGroupInputDescription 字段改为 *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 ./... 通过

@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA. ✅
Posted by the CLA Assistant Lite bot.

UpdateGroup 之前用 `if input.Description != ""` 判空,
把"未提供"和"显式置空"混为一谈,导致管理员在分组编辑表单
里清空备注后保存无效。

将 UpdateGroupRequest / UpdateGroupInput 的 Description 改为
*string:nil 表示未提供(保持原值),"" 表示显式清空。
@ghostg00 ghostg00 force-pushed the fix/admin-group-clear-description branch from e5c9216 to bc7ce18 Compare June 4, 2026 11:48
@ghostg00

ghostg00 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

Note on the failing Security Scan / backend-security check

This failure is unrelated to the diff in this PR. It's govulncheck flagging Go stdlib CVEs in the CI's Go toolchain:

  • GO-2026-5039net/textproto@go1.26.3 → fixed in go1.26.4
  • GO-2026-5037crypto/x509@go1.26.3 → fixed in go1.26.4

Evidence this is pre-existing on main and not caused by this PR:

  • The same Security Scan job is currently failing on main itself (run #26939055319, push from PR fix(usage): revert OpenAI 5h used_percent inversion (#2918 regression) #2993 merged into main).
  • The vulnerability traces point only to internal/handler/admin/setting_handler.go, internal/pkg/tlsfingerprint/dialer.go, internal/service/email_service.go, internal/service/gateway_service.gonone of which this PR touches. The diff in this PR is limited to group_handler.go / admin_service.go / admin_service_group_test.go.

The fix is to bump the CI Go toolchain to 1.26.4+ (separate maintenance task). All other checks on this PR are green: CI / frontend, golangci-lint, test, CLA.

@Wei-Shaw Wei-Shaw merged commit fbd25ac into Wei-Shaw:main Jun 5, 2026
6 of 7 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants