Skip to content

fix(wiki): retry node copy lock contention - #2292

Open
liujinkun2025 wants to merge 1 commit into
mainfrom
fix/wiki-node-copy-lock-retry
Open

fix(wiki): retry node copy lock contention#2292
liujinkun2025 wants to merge 1 commit into
mainfrom
fix/wiki-node-copy-lock-retry

Conversation

@liujinkun2025

@liujinkun2025 liujinkun2025 commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • retry wiki +node-copy when the Wiki API returns lock-contention code 131009
  • use two bounded exponential-backoff retries (250 ms and 500 ms) while leaving all other errors untouched
  • preserve the typed error metadata, cause, and upstream recovery hint when retries are exhausted
  • document the retry behavior and add regression coverage for success, non-retryable errors, and exhaustion

Safety

Retries are limited to the explicit 131009 response, which represents write-lock contention. Network failures and other API errors are not retried, avoiding ambiguous retries for this non-idempotent operation.

Testing

  • go test ./shortcuts/wiki/...
  • node scripts/skill-format-check/index.js
  • git diff --check

Summary by CodeRabbit

  • Bug Fixes

    • Wiki node copy now automatically retries lock-contention failures up to two times.
    • Retries use increasing delays and honor cancellation or timeout requests.
    • Clearer guidance is provided when all retry attempts fail.
    • Other error types continue to fail without unnecessary retries, while preserving useful error details.
  • Documentation

    • Added guidance for resolving persistent Wiki write contention, including avoiding concurrent writes under the same parent.

@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: 5a26db0f-e538-47b2-a7d4-808c7716f6ab

📥 Commits

Reviewing files that changed from the base of the PR and between fdc5c5a and e17f8e1.

📒 Files selected for processing (2)
  • shortcuts/wiki/wiki_list_copy_test.go
  • shortcuts/wiki/wiki_node_copy.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • shortcuts/wiki/wiki_node_copy.go
  • shortcuts/wiki/wiki_list_copy_test.go

📝 Walkthrough

Walkthrough

Wiki node copy now retries lock-contention errors with bounded exponential backoff, respects context cancellation, preserves typed error details, and documents the behavior. Tests cover successful retries, non-retryable errors, cancellation, and retry exhaustion.

Changes

Wiki node copy retry

Layer / File(s) Summary
Retry entrypoint and configuration
shortcuts/wiki/wiki_node_copy.go
The copy operation defines two retries with a 250 ms base delay. It passes the prepared API path and request body to runWikiNodeCopyWithRetry.
Contention retry and error preservation
shortcuts/wiki/wiki_node_copy.go
Lock-contention errors trigger exponential retries. Context cancellation and deadline expiration return non-retryable network errors. Unrelated errors propagate immediately. Exhausted retries preserve typed details and add contention guidance.
Retry behavior validation and documentation
shortcuts/wiki/wiki_list_copy_test.go, skills/lark-wiki/references/lark-wiki-node-copy.md
Tests cover retry success, unrelated errors, interrupted backoff, exhausted retries, and preserved causes. The reference documents the retry behavior.

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

Sequence Diagram(s)

sequenceDiagram
  participant RunWikiNodeCopy
  participant runWikiNodeCopyWithRetry
  participant WikiAPI
  participant Context
  RunWikiNodeCopy->>runWikiNodeCopyWithRetry: prepared API path and request body
  runWikiNodeCopyWithRetry->>WikiAPI: copy wiki node
  WikiAPI-->>runWikiNodeCopyWithRetry: lock-contention error
  runWikiNodeCopyWithRetry->>Context: check cancellation during backoff
  runWikiNodeCopyWithRetry->>WikiAPI: retry copy request
  WikiAPI-->>runWikiNodeCopyWithRetry: success or final wrapped error
  runWikiNodeCopyWithRetry-->>RunWikiNodeCopy: copied node data or preserved error contract
Loading

Possibly related PRs

  • larksuite/cli#2129: Both changes modify Wiki/Drive node-copy functionality and its documentation.
  • larksuite/cli#2238: Both changes modify Wiki node-copy behavior, tests, and documentation.

Suggested reviewers: liangshuo-1

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the main change: retrying wiki node-copy lock contention.
Description check ✅ Passed The description covers the motivation, implementation, safety, documentation, regression tests, and verification commands, but uses alternate headings and omits Related Issues.
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/wiki-node-copy-lock-retry

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.

@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 `@shortcuts/wiki/wiki_list_copy_test.go`:
- Around line 627-646: Extend TestRunWikiNodeCopyDoesNotRetryOtherErrors to
inspect errs.ProblemOf(err) and assert the returned error has
errs.CategoryAuthorization and errs.SubtypePermissionDenied metadata, while
retaining the existing single-call and cause-preservation assertions.

In `@shortcuts/wiki/wiki_node_copy.go`:
- Around line 125-129: Update the cancellation branch in the backoff select to
return a *errs.NetworkError, using SubtypeNetworkTimeout for deadline expiry and
SubtypeNetworkTransport for other cancellations, while preserving ctx.Err() via
WithCause. Add a backoff-cancellation test that verifies the error metadata and
cause and confirms no additional API call occurs.
🪄 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: 6ec0eb3d-339f-4405-a249-e6461c2ef910

📥 Commits

Reviewing files that changed from the base of the PR and between 79eb16c and fdc5c5a.

📒 Files selected for processing (3)
  • shortcuts/wiki/wiki_list_copy_test.go
  • shortcuts/wiki/wiki_node_copy.go
  • skills/lark-wiki/references/lark-wiki-node-copy.md

Comment thread shortcuts/wiki/wiki_list_copy_test.go
Comment thread shortcuts/wiki/wiki_node_copy.go
@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@e17f8e18ebfe51e8d5d8dc70d459eaecabb9fcb4

🧩 Skill update

npx skills add larksuite/cli#fix/wiki-node-copy-lock-retry -y -g

@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.11111% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.45%. Comparing base (79eb16c) to head (e17f8e1).
⚠️ Report is 17 commits behind head on main.

Files with missing lines Patch % Lines
shortcuts/wiki/wiki_node_copy.go 91.11% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2292      +/-   ##
==========================================
- Coverage   76.47%   76.45%   -0.02%     
==========================================
  Files        1013     1025      +12     
  Lines      112079   113750    +1671     
==========================================
+ Hits        85709    86967    +1258     
- Misses      19858    20110     +252     
- Partials     6512     6673     +161     

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

@liujinkun2025
liujinkun2025 force-pushed the fix/wiki-node-copy-lock-retry branch from fdc5c5a to e17f8e1 Compare August 12, 2026 10:20
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