fix(im): cap basic_batch user_ids at 10 per API limit#551
fix(im): cap basic_batch user_ids at 10 per API limit#551YangJunzhou-01 merged 1 commit intolarksuite:mainfrom
Conversation
The POST /contact/v3/users/basic_batch endpoint caps user_ids at 1~10 per request, but batchResolveByBasicContact was chunking by 50. When user identity needed to resolve >10 unresolved sender names, the single oversized request was rejected, causing the batch resolver to bail out and leave sender names empty for the rest. Lower batchSize to 10 and add a unit test that exercises 25 missing IDs and asserts they are sent as 10 / 10 / 5.
📝 WalkthroughWalkthroughReduced the batch size constant from 50 to 10 in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #551 +/- ##
=======================================
Coverage ? 59.96%
=======================================
Files ? 388
Lines ? 33147
Branches ? 0
=======================================
Hits ? 19878
Misses ? 11400
Partials ? 1869 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@5d200a6c6e3a1b800a3694729654471e61f34bba🧩 Skill updatenpx skills add haozhenghua-code/larksuite-cli#fix/basic-batch-size -y -g |
Summary
The
POST /contact/v3/users/basic_batchendpoint accepts 1~10user_idsper request (doc).batchResolveByBasicContactinshortcuts/im/convert_lib/helpers.gowas chunking by 50, so whenever the user-identity sender-name resolver had >10 unresolved IDs, the single oversized request was rejected and the whole batch was silently skipped — leaving sender names empty in the output ofim +chat-messages-list,+messages-search,+messages-mget,+threads-messages-list, etc.Changes
shortcuts/im/convert_lib/helpers.go: lowerbatchSizefrom 50 to 10 inbatchResolveByBasicContactand add a comment citing the API limit. The siblingbatchResolveUsers(calls the differentGET /contact/v3/users/batchendpoint, cap 50) is untouched.shortcuts/im/convert_lib/helpers_test.go: addTestBatchResolveByBasicContactRespectsAPILimitthat feeds 25 missing IDs and asserts the mock server sees three requests of size 10 / 10 / 5 and that every resolved name ends up in the name map.Test Plan
Automated
go test ./shortcuts/im/convert_lib/...passes (new + existing tests)go vet ./...andgo build ./...cleanEnd-to-end (built binary, live Feishu API)
Exercised the real
im +chat-messages-listflow on two internal group chats (chat IDs and user identifiers redacted). Compared the number of unique user senders vs. how many ended up with their display name populated afterResolveSenderNames→AttachSenderNames.batchSizebatchResolveUserspath, different API)batchSizeto 50 (reproduces the bug)The negative run demonstrates the bug was real: with 31 unresolved IDs packed into a single oversized request, the server rejects it and the resolver's
breakleaves the whole name map empty. After the fix, the same 31 IDs are split across 4 batches (10/10/10/1) and every name comes back.Related Issues