Skip to content

fix(drive): harden push failure handling - #2277

Closed
fangshuyu-768 wants to merge 4 commits into
mainfrom
fix/drive-push-error-guidance
Closed

fix(drive): harden push failure handling#2277
fangshuyu-768 wants to merge 4 commits into
mainfrom
fix/drive-push-error-guidance

Conversation

@fangshuyu-768

@fangshuyu-768 fangshuyu-768 commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

Harden drive +push batch control so deterministic or shared failures do not fan out across the remaining batch, using only error signals available on the command's real response path.

Changes

  • classify 1062009 as the file-local upload_size_mismatch before the generic invalid-parameters branch, allowing independent files to continue
  • stop the batch on Drive resource contention, global storage quota, multipart internal errors, and HTTP/network failures
  • use command-owned bounded-backoff guidance instead of forwarding arbitrary upstream hints or encouraging immediate replay
  • document the retry contract and add regression coverage for size mismatch, HTTP 502, resource contention, quota exhaustion, and Drive code 1663

Test Plan

  • go test ./shortcuts/drive ./internal/errclass -count=1
  • make unit-test
  • make vet
  • make fmt-check
  • node scripts/skill-format-check/index.js
  • make quality-gate
  • Live tenant verification was not run; deterministic HTTP stubs cover the changed API behavior without writing Drive data

Related Issues

  • None

Summary by CodeRabbit

  • Bug Fixes

    • Improved Google Drive upload failure handling with clearer diagnostics and troubleshooting guidance.
    • Upload size mismatches now allow independent files to continue processing.
    • Improved handling for server errors, conflicts, rate limits, quotas, and network failures.
    • Retryable failures now include retry timing and relevant console or log links.
    • Multipart upload internal failures are now classified for automatic retry.
    • Quota exhaustion is correctly identified as non-retryable.
  • Documentation

    • Expanded Drive push error classifications and bounded retry recommendations.

@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 11, 2026
@coderabbitai

coderabbitai Bot commented Aug 11, 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: 3f741eaf-71ba-4613-a9fa-9ed385d1ae7d

📥 Commits

Reviewing files that changed from the base of the PR and between 0c6b726 and 64995a3.

📒 Files selected for processing (3)
  • shortcuts/drive/drive_push.go
  • shortcuts/drive/drive_push_test.go
  • skills/lark-drive/references/lark-drive-push.md
💤 Files with no reviewable changes (1)
  • shortcuts/drive/drive_push.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • skills/lark-drive/references/lark-drive-push.md
  • shortcuts/drive/drive_push_test.go

📝 Walkthrough

Walkthrough

Drive push failure handling now preserves structured retry and diagnostic metadata. Classification distinguishes upload, server, conflict, quota, network, parameter, and local-file errors. Tests and documentation cover updated batch behavior and retry guidance.

Changes

Drive push failure handling

Layer / File(s) Summary
Error metadata contract
internal/errclass/codemeta_drive.go, internal/errclass/codemeta_test.go
Registers Drive code 1663 as a retryable server error and verifies its metadata.
Failure classification and batch output
shortcuts/drive/drive_push.go
Classifies Drive push failures and adds explicit retry guidance. Quota errors use separate terminal, non-retryable handling.
Behavioral validation and push guidance
shortcuts/drive/drive_push_test.go, skills/lark-drive/references/lark-drive-push.md
Tests partial and aborted batches, HTTP 502 failures, folder conflicts, quota failures, and retry metadata. Documents typed hints and bounded exponential backoff with jitter.

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

Possibly related PRs

Suggested labels: bug

Suggested reviewers: liangshuo-1

Sequence Diagram(s)

sequenceDiagram
  participant DrivePush
  participant DriveAPI
  participant FailureClassifier
  participant BatchResult
  DrivePush->>DriveAPI: upload file or create folder
  DriveAPI-->>DrivePush: success or typed error
  DrivePush->>FailureClassifier: classify failure and extract hints
  FailureClassifier-->>DrivePush: category, retryability, and backoff guidance
  DrivePush->>BatchResult: record partial or aborted push result
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: hardening Drive push failure handling.
Description check ✅ Passed The description includes all template sections, explains the failure-handling changes, and lists comprehensive validation results.
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-push-error-guidance

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 commented Aug 11, 2026

Copy link
Copy Markdown

PR Quality Summary

CI did not complete successfully. Use the failed check links below to decide whether this PR needs a code change or a rerun.

Failed checks

  • security — cancelled — details
  • fast-gate — cancelled — details
  • license-header — cancelled — details
  • coverage — cancelled — details
  • plugin-integration — cancelled — details
  • deadcode — cancelled — details
  • script-test — cancelled — details
  • deterministic-gate — cancelled — details
  • unit-test — cancelled — details
  • lint — cancelled — details
  • results — failure — details
  • sidecar-integration — cancelled — details
  • e2e-dry-run — cancelled — details
  • e2e-live — cancelled — details

deterministic-gate

  • System issue: deterministic-gate failed, but quality-gate facts were unavailable. expected exactly one base-bound quality gate facts artifact, got 0

@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add larksuite/cli#fix/drive-push-error-guidance -y -g

@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.76923% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.46%. Comparing base (a18ccd6) to head (64995a3).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
shortcuts/drive/drive_push.go 80.76% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2277      +/-   ##
==========================================
+ Coverage   76.44%   76.46%   +0.01%     
==========================================
  Files        1013     1013              
  Lines      111957   111995      +38     
==========================================
+ Hits        85588    85632      +44     
+ Misses      19859    19856       -3     
+ Partials     6510     6507       -3     

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

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
skills/lark-drive/references/lark-drive-push.md (2)

150-151: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Document the network failure class.

The PR objectives include network failures, but this table documents rate limits, conflicts, and server errors only. A transport failure without an HTTP status does not match HTTP 5xx, so agents have no documented batch or retry rule. Add the emitted network error class and specify its finite retry policy.

Based on the PR objectives, network failures are part of the classification contract.

🤖 Prompt for 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.

In `@skills/lark-drive/references/lark-drive-push.md` around lines 150 - 151,
Extend the error-classification table in lark-drive-push.md with the emitted
network/transport failure class for errors without an HTTP status, and document
that it stops the current batch and uses bounded backoff retries. Keep the
existing rate-limit, conflict, and server-error entries unchanged.

123-123: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Expose retry_after_seconds in items[]. The client stores the server delay on typed errors, but drivePushItem drops it and emits only hint. Add an integer retry_after_seconds field, omit it when unavailable, and document that agents must wait at least this duration before bounded backoff and jitter.

🤖 Prompt for 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.

In `@skills/lark-drive/references/lark-drive-push.md` at line 123, Update
drivePushItem’s failed-item output to propagate the typed error’s server delay
as an integer retry_after_seconds field, omitting the field when unavailable
while preserving the existing hint and error metadata. Document in the items[]
schema that agents must wait at least this duration before applying bounded
backoff and jitter.
🤖 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.

Outside diff comments:
In `@skills/lark-drive/references/lark-drive-push.md`:
- Around line 150-151: Extend the error-classification table in
lark-drive-push.md with the emitted network/transport failure class for errors
without an HTTP status, and document that it stops the current batch and uses
bounded backoff retries. Keep the existing rate-limit, conflict, and
server-error entries unchanged.
- Line 123: Update drivePushItem’s failed-item output to propagate the typed
error’s server delay as an integer retry_after_seconds field, omitting the field
when unavailable while preserving the existing hint and error metadata. Document
in the items[] schema that agents must wait at least this duration before
applying bounded backoff and jitter.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3220aa9e-bd75-4d97-9331-519528ee6c16

📥 Commits

Reviewing files that changed from the base of the PR and between 142cbdb and 0c6b726.

📒 Files selected for processing (3)
  • shortcuts/drive/drive_push.go
  • shortcuts/drive/drive_push_test.go
  • skills/lark-drive/references/lark-drive-push.md
💤 Files with no reviewable changes (1)
  • shortcuts/drive/drive_push_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • shortcuts/drive/drive_push.go

@fangshuyu-768

fangshuyu-768 commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded by #2279, which contains the complete final Drive push failure-handling diff from this PR (head 64995a3) together with the related Drive export recovery work. The four commits were cherry-picked patch-for-patch; no additional review-suggestion changes such as retry_after_seconds propagation were carried over. Further review and CI follow-up will continue in #2279.

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.

1 participant