refactor: Vec 必填字段统一用 validate_required_list! (#203)#207
Conversation
替换 12 处 Vec 字段的 validate_required! 为 validate_required_list!, 补充长度上限校验(user_ids=50, records=100, shifts=100 等)。 注:bank_card/recognize.rs 的 file: Vec<u8> 是二进制 blob 而非元素列表, 保留 validate_required! 只校验非空。 涉及 crate: hr(8) docs(2) ai(1) platform(1)
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8d41d8870f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| validate_required!(self.app_token.trim(), "app_token"); | ||
| validate_required!(self.table_id.trim(), "table_id"); | ||
| validate_required!(self.records, "records"); | ||
| validate_required_list!(self.records, 100, "records 不能为空且不能超过 100 个"); |
There was a problem hiding this comment.
Restore the 500-record create limit
When a caller submits 101–500 records, this new validate_required_list! guard returns a validation error before the existing if self.records.len() > 500 check runs, even though this request's own docs/tests model 500 records as the supported batch size. This regresses valid batch-create calls that previously passed SDK validation.
Useful? React with 👍 / 👎.
| validate_required!(self.app_token.trim(), "app_token"); | ||
| validate_required!(self.table_id.trim(), "table_id"); | ||
| validate_required!(self.records, "records"); | ||
| validate_required_list!(self.records, 100, "records 不能为空且不能超过 100 个"); |
There was a problem hiding this comment.
Restore the 500-record update limit
For batch updates with 101–500 records, this new limit rejects the request before the existing if self.records.len() > 500 validation can apply, while the surrounding code and tests still treat 500 as the allowed batch size. This prevents users from sending valid larger update batches that the SDK accepted before this change.
Useful? React with 👍 / 👎.
| ) -> SDKResult<CreateBadgeGrantResponse> { | ||
| validate_required!(self.badge_id, "勋章ID不能为空"); | ||
| validate_required!(self.user_ids, "用户ID列表不能为空"); | ||
| validate_required_list!(self.user_ids, 50, "用户ID列表不能为空且不能超过 50 个"); |
There was a problem hiding this comment.
Allow full badge grant recipient batches
The Feishu badge-grant API allows a manual grant list to associate 1–500 user groups when is_grant_all is false, and this builder only exposes user_ids, so a grant list for 51–500 users is a valid call that used to pass SDK validation. This new 50-item cap blocks those valid bulk grant creations client-side.
Useful? React with 👍 / 👎.
改动
将 12 处
Vec必填字段的validate_required!替换为validate_required_list!,补充长度上限校验。MAX_LEN 取值依据
按仓库现有 23 处
validate_required_list!的惯例:user_ids/employee_ids/field_ids: 50records/shifts: 100texts: 50探索修正
原计划 13 处,实施中发现
bank_card/recognize.rs的file: Vec<u8>是二进制 blob(文件内容字节序列)而非元素列表,validate_required_list!的len() > max_len检查对字节数无意义。该处保留validate_required!只校验非空,实际替换 12 处。涉及 crate
测试
Closes #203