feat: add failed_member_ids - #29
Conversation
Walkthrough在 Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Client as Client
participant Service as Recruit Service
participant DingTalk as DingTalk API
Client->>Service: CreateRecruitChatGroup(request: member_ids, ...)
Service->>DingTalk: Create chat group + add members
alt 部分成员添加失败
DingTalk-->>Service: result + failed list
Service-->>Client: CreateRecruitChatGroupResponse<br/>(..., failed_member_ids)
else 全部成功
DingTalk-->>Service: result (no failures)
Service-->>Client: CreateRecruitChatGroupResponse<br/>(..., failed_member_ids="")
end
note over Client,Service: 新增响应字段 failed_member_ids(tag 4)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
consultingapis/dingtalk/v1/dingtalk.proto (1)
151-156: 可选:若需返回失败原因,补充结构化原因映射若需要同时告知失败原因,建议新增结构化字段,避免日志/字符串拼接。
示例一(轻量):
message CreateRecruitChatGroupResponse{ string chat_id = 1; string openConversationId = 2; string invite_url = 3; repeated string failed_member_ids = 4; + map<string, string> failed_member_reasons = 5; // key: member_id, value: 失败原因 }示例二(更可拓展):
message FailedMember { string id = 1; string reason = 2; } message CreateRecruitChatGroupResponse{ string chat_id = 1; string openConversationId = 2; string invite_url = 3; repeated string failed_member_ids = 4; repeated FailedMember failed_members = 5; }
| string chat_id = 1; | ||
| string openConversationId = 2; | ||
| string invite_url = 3; | ||
| string failed_member_ids = 4; |
There was a problem hiding this comment.
🛠️ Refactor suggestion
🧩 Analysis chain
将 failed_member_ids 改为 repeated 字段,避免非结构化返回
该字段语义是“多个失败成员 ID”。用 string 会迫使客户端自行解析(逗号分隔/JSON 等),且与请求体里 Body.member_id 的 repeated string 不对称。建议直接返回列表,便于多语言 SDK 生成强类型集合。
应用如下变更:
-message CreateRecruitChatGroupResponse{
+message CreateRecruitChatGroupResponse{
string chat_id = 1;
string openConversationId = 2;
string invite_url = 3;
- string failed_member_ids = 4;
+ repeated string failed_member_ids = 4; // 添加失败的成员ID列表
}请在本仓库跑一遍代码生成并检索调用点,确认下游未假定为字符串:
🏁 Script executed:
#!/bin/bash
# 验证响应结构体/字段的使用点(Go/TS/Java 常见后缀做个基本覆盖)
rg -n -C2 'CreateRecruitChatGroupResponse|failed_member_ids' -g '!**/node_modules/**' -g '!**/dist/**' -g '!**/build/**'Length of output: 148
重新运行更全面的搜索并打印相关 proto 片段:
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "工作目录: $(pwd)"
echo "---- 全库搜索 CreateRecruitChatGroupResponse / failed_member_ids ----"
rg -n -S --hidden --no-ignore-vcs 'CreateRecruitChatGroupResponse|failed_member_ids|failedMemberIds|FailedMemberIds' || true
echo "---- 打印 consultingapis/dingtalk/v1/dingtalk.proto(如存在,前 240 行) ----"
if [ -f consultingapis/dingtalk/v1/dingtalk.proto ]; then
sed -n '1,240p' consultingapis/dingtalk/v1/dingtalk.proto || true
else
echo "文件 consultingapis/dingtalk/v1/dingtalk.proto 未找到"
fi
echo "---- 在所有 .proto 中查找消息定义 ----"
rg -n --hidden --no-ignore-vcs 'message CreateRecruitChatGroupResponse' -g '**/*.proto' || true
echo "---- 在常见生成文件中查找字段用法(.pb.go, .ts, .java, .js) ----"
rg -n --hidden --no-ignore-vcs 'CreateRecruitChatGroupResponse|failed_member_ids|failedMemberIds|FailedMemberIds' -g '**/*.pb.go' -g '**/*.ts' -g '**/*.js' -g '**/*.java' || trueLength of output: 9098
将 failed_member_ids 改为 repeated string 并同步更新生成产物
理由:字段语义为“多个失败成员 ID”,应与请求体 Body.member_id (repeated string) 对齐,避免客户端自行解析。
仓库检索结果:该字段目前只出现在 consultingapis/dingtalk/v1/dingtalk.proto(当前为 string)及生成产物 consultingapis/dingtalk/v1/dingtalk.pb.go、consultingapis/dingtalk/v1/dingtalk_grpc.pb.go、docs/swagger/consultingapis/dingtalk/v1/dingtalk.swagger.json,未发现其他业务代码直接依赖字符串格式。风险在于必须同步重新生成产物并提交。
操作(必做):
- 修改 proto(见下 diff)。
- 重新运行 protoc / 生成脚本,提交更新的 .pb.go、_grpc.pb.go 与 swagger/json,并在修改后再次全库搜索与编译/测试确认无破坏。
-message CreateRecruitChatGroupResponse{
+message CreateRecruitChatGroupResponse{
string chat_id = 1;
string openConversationId = 2;
string invite_url = 3;
- string failed_member_ids = 4;
+ repeated string failed_member_ids = 4; // 添加失败的成员ID列表
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| string failed_member_ids = 4; | |
| message CreateRecruitChatGroupResponse{ | |
| string chat_id = 1; | |
| string openConversationId = 2; | |
| string invite_url = 3; | |
| repeated string failed_member_ids = 4; // 添加失败的成员ID列表 | |
| } |
Summary by CodeRabbit