Skip to content

refactor: Vec 必填字段统一用 validate_required_list! (#203)#207

Merged
foxzool merged 1 commit into
mainfrom
fix/issue-203-validate-list
Jun 15, 2026
Merged

refactor: Vec 必填字段统一用 validate_required_list! (#203)#207
foxzool merged 1 commit into
mainfrom
fix/issue-203-validate-list

Conversation

@foxzool

@foxzool foxzool commented Jun 15, 2026

Copy link
Copy Markdown
Owner

改动

将 12 处 Vec 必填字段的 validate_required! 替换为 validate_required_list!,补充长度上限校验。

MAX_LEN 取值依据

按仓库现有 23 处 validate_required_list! 的惯例:

  • user_ids/employee_ids/field_ids: 50
  • records/shifts: 100
  • texts: 50

探索修正

原计划 13 处,实施中发现 bank_card/recognize.rsfile: Vec<u8> 是二进制 blob(文件内容字节序列)而非元素列表,validate_required_list!len() > max_len 检查对字节数无意义。该处保留 validate_required! 只校验非空,实际替换 12 处。

涉及 crate

  • openlark-hr: 8 处
  • openlark-docs: 2 处
  • openlark-ai: 1 处(translate.rs)
  • openlark-platform: 1 处

测试

  • HR: 1254 测试通过
  • AI: 212 测试通过
  • Platform: 34 测试通过
  • docs crate 测试有预存 feature flag 错误(main 分支同样存在,非本次引入)

Closes #203

替换 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)
@foxzool foxzool added type:refactor 架构或接口收敛性重构 priority:p1 高优先级 scope:api typed API 覆盖率、API 缺口与模型实现 labels Jun 15, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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 个");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 个");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 个");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@foxzool foxzool merged commit fb2cd6a into main Jun 15, 2026
122 checks passed
@foxzool foxzool deleted the fix/issue-203-validate-list branch June 15, 2026 06:30
foxzool added a commit that referenced this pull request Jun 16, 2026
PR #207 误将 records 上限设为 100,与飞书官方上限 1000 冲突,
且原 500 业务规则成为死代码。改为 1000 并删除冗余检查。

code review (PR #206/#207) 发现的问题。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority:p1 高优先级 scope:api typed API 覆盖率、API 缺口与模型实现 type:refactor 架构或接口收敛性重构

Projects

None yet

Development

Successfully merging this pull request may close these issues.

P1:推广 validate_required_list! 到所有 Vec 必填字段

1 participant