perf(drive): optimize drive +delete workflow#1909
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughDrive deletion now always uses asynchronous requests with task polling for files and folders. Outputs include task state and continuation data, while unit, E2E, documentation, and coverage updates validate the unified workflow. ChangesDrive asynchronous deletion
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant CLI
participant DriveDelete
participant DriveAPI
participant TaskResult
CLI->>DriveDelete: drive +delete
DriveDelete->>DriveAPI: Async DELETE
DriveAPI-->>DriveDelete: task_id or immediate success
DriveDelete->>DriveAPI: task_check polling
DriveAPI-->>DriveDelete: status
DriveDelete-->>CLI: ready or next_command
CLI->>TaskResult: drive +task_result
TaskResult->>DriveAPI: Query task_id
DriveAPI-->>TaskResult: Final task status
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@622fe81f259f61780824ab30504d563d2f4b5bb0🧩 Skill updatenpx skills add larksuite/cli#fix/drive-delete-async -y -g |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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_delete_test.go`:
- Around line 146-157: Replace substring-based assertions with structured
contract checks throughout shortcuts/drive/drive_delete_test.go: at lines
146-157 decode the delete result and verify every changed field, including
status and type; at lines 160-183 assert the typed error category and
SubtypeInvalidResponse; at lines 203-220 define typed expected task-result
fields; at lines 285-289 decode stdout and compare the structured expectation;
and at lines 333-353 reset the buffer before resumption or decode each emitted
result separately.
In `@shortcuts/drive/drive_task_result.go`:
- Line 228: Update the task_check dry-run description in
shortcuts/drive/drive_task_result.go at lines 109 and 228 to remove the
remaining “folder” wording. Also update
skills/lark-drive/references/lark-drive-task-result.md at lines 70 to change
“Drive 移动删除任务” to “Drive 移动/删除任务”.
🪄 Autofix (Beta)
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
Run ID: b3e38c8d-f71f-4af5-80a3-cc0a6d7d07ee
📒 Files selected for processing (10)
shortcuts/drive/drive_delete.goshortcuts/drive/drive_delete_test.goshortcuts/drive/drive_move_common.goshortcuts/drive/drive_task_result.goskills/lark-drive/references/lark-drive-delete.mdskills/lark-drive/references/lark-drive-task-result.mdtests/cli_e2e/drive/coverage.mdtests/cli_e2e/drive/drive_delete_dryrun_test.gotests/cli_e2e/drive/drive_delete_workflow_test.gotests/cli_e2e/drive/helpers.go
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1909 +/- ##
==========================================
+ Coverage 74.77% 74.96% +0.18%
==========================================
Files 888 892 +4
Lines 92946 94058 +1112
==========================================
+ Hits 69502 70506 +1004
- Misses 18078 18139 +61
- Partials 5366 5413 +47 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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_delete_test.go`:
- Around line 200-211: The deletion test’s stdout checks in the current test
function should structurally validate the JSON response instead of searching for
substrings. Decode stdout into the expected response structure, assert deleted,
file_token, and type fields directly, and verify task_id is absent for the
synchronous-success fallback while preserving the existing failure diagnostics.
🪄 Autofix (Beta)
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
Run ID: 6944afa3-f402-445d-92f5-4b80a1812a78
📒 Files selected for processing (3)
shortcuts/drive/drive_delete.goshortcuts/drive/drive_delete_test.goskills/lark-drive/references/lark-drive-delete.md
🚧 Files skipped from review as they are similar to previous changes (2)
- skills/lark-drive/references/lark-drive-delete.md
- shortcuts/drive/drive_delete.go
8ff6723 to
4ed0185
Compare
4ed0185 to
622fe81
Compare
Summary
Optimize the
drive +deleteworkflow to improve reliability for long-running Drive deletions without changing the command surface.Changes
Test Plan
go test ./shortcuts/drive -run 'TestDriveDelete|TestValidateDriveDelete' -count=1\n- [x] Dry-run E2E passes:go test ./tests/cli_e2e/drive -run TestDriveDeleteDryRunAsyncParams -count=1\n- [x] Live E2E passes:go test ./tests/cli_e2e/drive -run TestDrive_DeleteAsyncWorkflow -count=1 -v\n\n## Related Issues\n- NoneSummary by CodeRabbit
drive +deletenow always issues async deletes for files and folders, with reliable task status polling; timed-out operations can be resumed viadrive +task_result.async=trueand the required follow-up task-check step; fallback behavior is improved when notask_idis returned.drive +deleteanddrive +task_resultdocs and wording to consistently describe Drive move/delete async polling and resume flows.