Skip to content

fix(drive): stop export polling on rate limits - #2192

Merged
fangshuyu-768 merged 2 commits into
mainfrom
fix/drive-export-rate-limit
Aug 5, 2026
Merged

fix(drive): stop export polling on rate limits#2192
fangshuyu-768 merged 2 commits into
mainfrom
fix/drive-export-rate-limit

Conversation

@wittam-01

@wittam-01 wittam-01 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Stop Drive export task polling immediately when OpenAPI returns rate_limit / 99991400, and give agents a task-aware one-minute backoff path.

Changes

  • Preserve the typed API error and stop consuming the remaining export polling attempts after rate limiting.
  • Distinguish task creation throttling (no ticket: retry the original export after backoff) from status throttling (existing ticket: resume with drive +task_result).
  • Add regression tests and concise lark-drive Skill guidance for one-minute exponential backoff.

Test Plan

  • go test ./shortcuts/drive -run '^(TestDriveExportCreateRateLimitSuggestsRetryingOriginalCommand|TestDriveExportRateLimitStopsPollingAndSuggestsOneMinuteBackoff|TestDriveExportRateLimitAfterObservedStatusReturnsError|TestDriveTaskResultExportRateLimitSuggestsOneMinuteBackoff)$' -count=1
  • git diff --check
  • Existing tests/cli_e2e/drive/drive_export_dryrun_test.go covers the unchanged drive +export request shape.
  • Live API verification was not run to avoid creating export tasks while the endpoint is being rate limited.

Related Issues

  • None

Summary by CodeRabbit

  • Bug Fixes

    • Improved Drive export handling when rate limits occur during task creation or status checks.
    • Added clear recovery guidance, including waiting at least one minute and retrying with appropriate backoff.
    • Preserved existing tickets during throttled status checks and prevented unnecessary duplicate export attempts.
  • Documentation

    • Added guidance for recovering from rate-limited Drive exports and task-result requests.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4a654121-2c2d-471a-a712-6b849e00cf1d

📥 Commits

Reviewing files that changed from the base of the PR and between 7363eb5 and c901404.

📒 Files selected for processing (8)
  • shortcuts/drive/drive_errors.go
  • shortcuts/drive/drive_export.go
  • shortcuts/drive/drive_export_common.go
  • shortcuts/drive/drive_export_test.go
  • shortcuts/drive/drive_task_result.go
  • shortcuts/drive/drive_task_result_test.go
  • skills/lark-drive/references/lark-drive-export.md
  • skills/lark-drive/references/lark-drive-task-result.md
🚧 Files skipped from review as they are similar to previous changes (8)
  • shortcuts/drive/drive_task_result.go
  • shortcuts/drive/drive_export_common.go
  • skills/lark-drive/references/lark-drive-task-result.md
  • shortcuts/drive/drive_export.go
  • skills/lark-drive/references/lark-drive-export.md
  • shortcuts/drive/drive_task_result_test.go
  • shortcuts/drive/drive_errors.go
  • shortcuts/drive/drive_export_test.go

📝 Walkthrough

Walkthrough

Drive export creation and status polling now detect rate-limit errors, preserve typed error metadata, and return different retry guidance based on ticket availability. Tests and Drive documentation cover one-minute waits, ticket reuse, and exponential backoff.

Changes

Drive export rate-limit recovery

Layer / File(s) Summary
Rate-limit recovery helpers
shortcuts/drive/drive_errors.go
Rate limits are detected by subtype or code 99991400. Task-status errors retain their classification and receive ticket-based retry guidance. Task-creation errors instruct callers to rerun the original export.
Export flow integration
shortcuts/drive/drive_export_common.go, shortcuts/drive/drive_export.go, shortcuts/drive/drive_task_result.go
Task creation and status polling pass rate-limit errors through the recovery helpers. Polling stops instead of treating the error as a generic transient failure.
Rate-limit validation and guidance
shortcuts/drive/drive_export_test.go, shortcuts/drive/drive_task_result_test.go, skills/lark-drive/references/*
Tests verify polling termination, typed errors, empty output, and context-specific commands. Documentation describes one-minute waits, ticket reuse, and exponential backoff.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ExportCommand
  participant DriveExport
  participant DriveAPI
  participant RecoveryHelper
  participant TaskResult
  ExportCommand->>DriveExport: create export task
  DriveExport->>DriveAPI: submit export request
  DriveAPI-->>DriveExport: rate-limit error
  DriveExport->>RecoveryHelper: add creation retry guidance
  RecoveryHelper-->>ExportCommand: wait and rerun export
  TaskResult->>DriveAPI: poll existing ticket
  DriveAPI-->>TaskResult: rate-limit error
  TaskResult->>RecoveryHelper: add ticket retry guidance
  RecoveryHelper-->>TaskResult: wait and retry with backoff
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the main change: stopping Drive export polling when rate limits occur.
Description check ✅ Passed The description includes the required Summary, Changes, Test Plan, and Related Issues sections with relevant implementation and verification details.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/drive-export-rate-limit

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added domain/ccm PR touches the ccm domain size/M Single-domain feat or fix with limited business impact labels Aug 5, 2026

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@shortcuts/drive/drive_export_test.go`:
- Around line 1425-1431: Extend the recovery-helper tests to cover subtype-only
rate-limit classification and cause preservation when
appendDriveExportRecoveryHint handles a typed error. In
shortcuts/drive/drive_export_test.go:1425-1431, add this helper-level assertion;
retain shortcuts/drive/drive_export_test.go:1474-1480 as the separate 99991400
code-based contract; and in shortcuts/drive/drive_task_result_test.go:182-187,
reuse the helper coverage or add the equivalent subtype-only +task_result
assertion.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a94953e9-f745-4783-93ca-fe40e34d54fa

📥 Commits

Reviewing files that changed from the base of the PR and between ebdeda8 and 80d00d0.

📒 Files selected for processing (9)
  • shortcuts/drive/drive_errors.go
  • shortcuts/drive/drive_export.go
  • shortcuts/drive/drive_export_common.go
  • shortcuts/drive/drive_export_test.go
  • shortcuts/drive/drive_task_result.go
  • shortcuts/drive/drive_task_result_test.go
  • skills/lark-drive/SKILL.md
  • skills/lark-drive/references/lark-drive-export.md
  • skills/lark-drive/references/lark-drive-task-result.md

Comment thread shortcuts/drive/drive_export_test.go
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@c9014040e9e0f22519b319e85b879def5d57a447

🧩 Skill update

npx skills add larksuite/cli#fix/drive-export-rate-limit -y -g

@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.60870% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.92%. Comparing base (ebdeda8) to head (c901404).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
shortcuts/drive/drive_errors.go 78.94% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2192      +/-   ##
==========================================
+ Coverage   75.85%   75.92%   +0.06%     
==========================================
  Files         958      962       +4     
  Lines      101701   102197     +496     
==========================================
+ Hits        77150    77591     +441     
- Misses      18684    18716      +32     
- Partials     5867     5890      +23     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread skills/lark-drive/references/lark-drive-task-result.md Outdated
Comment thread skills/lark-drive/SKILL.md Outdated
Comment thread skills/lark-drive/references/lark-drive-export.md Outdated
@wittam-01
wittam-01 force-pushed the fix/drive-export-rate-limit branch from 80d00d0 to 0aec299 Compare August 5, 2026 08:53
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

Comment thread shortcuts/drive/drive_errors.go

@fangshuyu-768 fangshuyu-768 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed the latest head c901404. Targeted Drive tests and the current CI suite pass; no remaining merge blockers.

@fangshuyu-768
fangshuyu-768 merged commit 0848a5b into main Aug 5, 2026
42 of 52 checks passed
@fangshuyu-768
fangshuyu-768 deleted the fix/drive-export-rate-limit branch August 5, 2026 10:40
@liangshuo-1 liangshuo-1 mentioned this pull request Aug 5, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain/ccm PR touches the ccm domain size/M Single-domain feat or fix with limited business impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants