Skip to content

fix: stabilize drive delete E2E terminal-state checks#1939

Merged
luozhixiong01 merged 4 commits into
mainfrom
fix/drive-delete-e2e-flake
Jul 17, 2026
Merged

fix: stabilize drive delete E2E terminal-state checks#1939
luozhixiong01 merged 4 commits into
mainfrom
fix/drive-delete-e2e-flake

Conversation

@luozhixiong01

@luozhixiong01 luozhixiong01 commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

TestDrive_DeleteAsyncWorkflow assumed every successful drive +delete returns an async task_id, so it flaked when Drive transiently reported drive task failed for a freshly created docx, and it would also fail on a synchronous delete (no task_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

  • Rework deleteAsyncAndVerify in tests/cli_e2e/drive/drive_delete_workflow_test.go: bounded retry loop (3 attempts) covering asynchronous success, synchronous success (empty task_id with deleted=true), and the verified drive task failed transient; add isTransientDriveDeleteFailure so only that one error may fall through to terminal-state checking; make drive +task_result verification fail fast on non-zero exit
  • Add tests/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 workflow
  • Update tests/cli_e2e/drive/coverage.md to describe the terminal-state convergence

Test Plan

  • make unit-test passed
  • validate passed (build, vet, unit, integration)
  • skipped: sandbox local-eval (test-only change with no new E2E or skill-eval artifacts; the modified live suite runs in this PR's e2e-live job)
  • acceptance-reviewer passed (2/2 cases; includes a mutation check that disabling the transient guard turns the subprocess contract test red)
  • manual verification: go test ./tests/cli_e2e/drive/ -run 'TestDeleteAsyncAndVerify|TestIsTransientDriveDeleteFailure|TestDeleteDriveResourceAndVerify' -count=1 -race — all green against the fake CLI, no real API calls

Related Issues

N/A

Summary by CodeRabbit

  • Bug Fixes

    • Improved Drive deletion workflow handling for both synchronous and asynchronous completion, including correct task polling behavior.
    • Added targeted retry handling for a specific transient backend failure until the resource is confirmed deleted.
    • Strengthened verification of deletion outcomes and failure modes.
  • Tests

    • Expanded end-to-end coverage for deleting docx, empty folders, and non-empty folders across sync/async/transient scenarios.
    • Added more rigorous checks for task-result success, retry exhaustion, and immediate abort behavior on unexpected failures.
  • Documentation

    • Updated E2E CLI coverage notes for the Drive delete command.

@luozhixiong01 luozhixiong01 added the bugfix Bug fixes label Jul 17, 2026
@coderabbitai

coderabbitai Bot commented Jul 17, 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

Run ID: 58e4ec81-6f8f-49ba-9a61-e61925ab11c9

📥 Commits

Reviewing files that changed from the base of the PR and between 4b4b72f and fd5bfda.

📒 Files selected for processing (2)
  • tests/cli_e2e/drive/drive_delete_workflow_helper_test.go
  • tests/cli_e2e/drive/drive_delete_workflow_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/cli_e2e/drive/drive_delete_workflow_test.go

📝 Walkthrough

Walkthrough

The 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.

Changes

Drive delete workflow

Layer / File(s) Summary
Delete workflow control flow
tests/cli_e2e/drive/drive_delete_workflow_test.go
deleteAsyncAndVerify distinguishes sync and async deletes, validates async task results, retries the tolerated transient failure up to the configured limit, and verifies the resource’s terminal state.
Deterministic workflow validation
tests/cli_e2e/drive/drive_delete_workflow_helper_test.go
Adds fake CLI-backed tests for sync deletion, async retry success, transient-error classification, unexpected failures, retry exhaustion, and endpoint call counts.
Coverage documentation
tests/cli_e2e/drive/coverage.md
Documents sync/async verification, transient-failure convergence, and live coverage for document and folder deletion scenarios.

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
Loading

Suggested labels: domain/ccm

Suggested reviewers: fangshuyu-768

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately reflects the main change: stabilizing Drive delete E2E terminal-state checks.
Description check ✅ Passed The description follows the required template with Summary, Changes, Test Plan, and Related Issues sections filled in.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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
📝 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-delete-e2e-flake

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 the size/S Low-risk docs, CI, test, or chore only changes label Jul 17, 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: 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

📥 Commits

Reviewing files that changed from the base of the PR and between 76ebd49 and 4b4b72f.

📒 Files selected for processing (3)
  • tests/cli_e2e/drive/coverage.md
  • tests/cli_e2e/drive/drive_delete_workflow_helper_test.go
  • tests/cli_e2e/drive/drive_delete_workflow_test.go

Comment thread tests/cli_e2e/drive/drive_delete_workflow_helper_test.go
Comment thread tests/cli_e2e/drive/drive_delete_workflow_test.go Outdated
@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add larksuite/cli#fix/drive-delete-e2e-flake -y -g

@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.96%. Comparing base (6c14c42) to head (fd5bfda).
⚠️ Report is 3 commits behind head on main.

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.
📢 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.

@luozhixiong01
luozhixiong01 merged commit 767386c into main Jul 17, 2026
68 checks passed
@luozhixiong01
luozhixiong01 deleted the fix/drive-delete-e2e-flake branch July 17, 2026 10:00
@liangshuo-1 liangshuo-1 mentioned this pull request Jul 17, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Bug fixes size/S Low-risk docs, CI, test, or chore only changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants