fix: stabilize drive delete E2E terminal-state checks#1939
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe Drive delete workflow now supports synchronous and asynchronous completion, bounded retries for a specific transient backend failure, task-result validation, and deterministic E2E coverage for success and failure paths. ChangesDrive delete workflow
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant DeleteWorkflow
participant DriveDeleteCLI
participant DriveTaskResultCLI
participant DriveMetaEndpoint
DeleteWorkflow->>DriveDeleteCLI: Execute drive +delete
DriveDeleteCLI-->>DeleteWorkflow: Return task_id or deleted=true
DeleteWorkflow->>DriveTaskResultCLI: Verify async task
DriveTaskResultCLI-->>DeleteWorkflow: Return task success
DeleteWorkflow->>DriveMetaEndpoint: Check resource state
DriveMetaEndpoint-->>DeleteWorkflow: Return resource state
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
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 `@tests/cli_e2e/drive/drive_delete_workflow_helper_test.go`:
- Around line 50-65: The existing test only covers eventual async success; add
adjacent subprocess cases for a non-zero task-result exit and for three
transient delete failures. Configure the fake CLI modes, invoke
deleteAsyncAndVerify, assert the expected failure, and verify exact delete,
metadata, and task-result counters; ensure the transient case stops at
deleteWorkflowMaxAttempts.
In `@tests/cli_e2e/drive/drive_delete_workflow_test.go`:
- Line 149: Update the assertion around taskResult.Stdout in the drive delete
workflow test to first require that data.failed exists, then assert its boolean
value is false. Do not rely on gjson.Get(...).Bool() alone, since a missing
field must fail validation rather than be coerced to false.
🪄 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: 230f4128-d06e-4dc6-9058-2ce2f0048fb7
📒 Files selected for processing (3)
tests/cli_e2e/drive/coverage.mdtests/cli_e2e/drive/drive_delete_workflow_helper_test.gotests/cli_e2e/drive/drive_delete_workflow_test.go
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@fd5bfdac75e64e7388a3e13a098a3957632f7e38🧩 Skill updatenpx skills add larksuite/cli#fix/drive-delete-e2e-flake -y -g |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1939 +/- ##
=======================================
Coverage 74.96% 74.96%
=======================================
Files 892 892
Lines 94077 94077
=======================================
Hits 70529 70529
Misses 18137 18137
Partials 5411 5411 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
TestDrive_DeleteAsyncWorkflowassumed every successfuldrive +deletereturns an asynctask_id, so it flaked when Drive transiently reporteddrive task failedfor a freshly created docx, and it would also fail on a synchronous delete (notask_id). The helper now checks the actual terminal state: it succeeds if the resource is already gone, otherwise it retries the verified transient with a bounded attempt count — while keeping all unrecognized errors fatal.Changes
deleteAsyncAndVerifyintests/cli_e2e/drive/drive_delete_workflow_test.go: bounded retry loop (3 attempts) covering asynchronous success, synchronous success (emptytask_idwithdeleted=true), and the verifieddrive task failedtransient; addisTransientDriveDeleteFailureso only that one error may fall through to terminal-state checking; makedrive +task_resultverification fail fast on non-zero exittests/cli_e2e/drive/drive_delete_workflow_helper_test.go: fake-CLI contract tests covering error-classification boundaries, exact delete/metadata/task-result call counts per scenario, and subprocess tests proving unexpected delete failures, task-result failures, and retry exhaustion all fail the workflowtests/cli_e2e/drive/coverage.mdto describe the terminal-state convergenceTest Plan
make unit-testpassedgo test ./tests/cli_e2e/drive/ -run 'TestDeleteAsyncAndVerify|TestIsTransientDriveDeleteFailure|TestDeleteDriveResourceAndVerify' -count=1 -race— all green against the fake CLI, no real API callsRelated Issues
N/A
Summary by CodeRabbit
Bug Fixes
Tests
Documentation
deletecommand.