fix: add rate limiting to DingTalk org sync API calls#374
Merged
wisdomqin merged 1 commit intodataelement:mainfrom Apr 12, 2026
Merged
fix: add rate limiting to DingTalk org sync API calls#374wisdomqin merged 1 commit intodataelement:mainfrom
wisdomqin merged 1 commit intodataelement:mainfrom
Conversation
DingTalk enforces ~20 QPS per app per API interface. The DingTalkOrgSyncAdapter was issuing requests in tight loops without any delay, causing QPS throttle errors (subcode=90018) during org sync for organizations with many departments. - Add 60ms delay between requests in fetch_departments() and fetch_users() to stay safely under the 20 QPS limit - Move asyncio import to module level (was locally imported in FeishuOrgSyncAdapter) - Consistent with FeishuOrgSyncAdapter which already uses Semaphore(15) for rate limiting Fixes dataelement#373
Contributor
|
Thanks for the fix! 🎉 Cherry-picked to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add request throttling to
DingTalkOrgSyncAdapterto prevent hitting DingTalk's API rate limit (~20 QPS per interface per app).The
fetch_departments()andfetch_users()methods were issuing HTTP requests in tight loops without any delay, causing QPS throttle errors (subcode=90018) when syncing organizations with many departments.Changes:
asyncio.sleep(0.06)) between consecutive API calls in bothfetch_departments()andfetch_users(), keeping the rate at ~16 QPSasyncioimport to module level (was locally imported inFeishuOrgSyncAdapter)FeishuOrgSyncAdapterwhich already usesSemaphore(15)for rate limitingFixes #373
Checklist