Skip to content

fix(output): classify wiki lock-contention error (131009) with retry hint#1014

Open
leeguooooo wants to merge 1 commit into
larksuite:mainfrom
leeguooooo:fix/classify-wiki-lock-contention
Open

fix(output): classify wiki lock-contention error (131009) with retry hint#1014
leeguooooo wants to merge 1 commit into
larksuite:mainfrom
leeguooooo:fix/classify-wiki-lock-contention

Conversation

@leeguooooo
Copy link
Copy Markdown

@leeguooooo leeguooooo commented May 21, 2026

Summary

Wiki write-path operations (most commonly wiki +node-create against the same parent) surface code 131009 "lock contention" under concurrent calls. Currently this falls through to the generic "api_error" classification, giving users no hint that it is transient and safe to retry.

This PR mirrors the existing LarkErrDriveResourceContention (1061045) treatment: add a named constant, classify as "conflict", and emit a hint that points the caller toward exponential backoff or serializing sibling-node writes.

Changes

  • Add LarkErrWikiLockContention = 131009 constant in internal/output/lark_errors.go
  • Classify it as (ExitAPI, "conflict", <retry hint>) alongside the existing Drive contention case
  • Add TestClassifyLarkError_WikiLockContention covering exit code / type / hint substring

Test Plan

  • gofmt -l ./internal/output/ — clean
  • go vet ./internal/output/... — clean
  • go test ./internal/output/... -run "WikiLock" -v — pass
  • make unit-test — pass

Scope note

This PR only adds classification + hint, matching the existing Drive contention precedent. It does not add client-side retry — that's left as a separate design decision (see issue #1012 for context). Downstream tools can already detect the "conflict" errType and retry on their side; this PR removes the need for downstream tools to hardcode 131009 themselves.

Related Issues

Summary by CodeRabbit

  • Bug Fixes
    • Improved error handling for wiki write operations that encounter lock contention, now classifying conflicts more clearly and providing explicit retry/backoff guidance to help automatic recovery.
  • Tests
    • Added a unit test to verify the conflict classification and that retry/backoff guidance is included for wiki lock contention scenarios.

Review Change Stack

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 21, 2026

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3183b0ad-253e-4390-8a9b-2ca59d56e3d8

📥 Commits

Reviewing files that changed from the base of the PR and between 52e0ce4 and ae3d352.

📒 Files selected for processing (2)
  • internal/output/lark_errors.go
  • internal/output/lark_errors_test.go

📝 Walkthrough

Walkthrough

Adds a new Lark API error constant for wiki write-lock contention, classifies it in ClassifyLarkError as an API conflict with a retry/backoff hint, and adds a unit test verifying the classification and hint text.

Changes

Wiki Lock Contention Error Handling

Layer / File(s) Summary
Wiki lock contention error classification
internal/output/lark_errors.go, internal/output/lark_errors_test.go
Adds LarkErrWikiLockContention = 131009; ClassifyLarkError returns ExitAPI with errType "conflict" and a hint referencing wiki write lock and backoff; unit test TestClassifyLarkError_WikiLockContention asserts exit code, type, and hint content.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I saw two writers tap and knock,
The wiki gates would briefly block—
Backoff, retry, then try again,
Locks loosened, pages mend. 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and specifically summarizes the main change: adding classification for wiki lock-contention error 131009 with retry hint.
Description check ✅ Passed The description follows the template structure with all required sections: Summary, Changes, Test Plan (with checkboxes), and Related Issues. All sections are complete and informative.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@github-actions github-actions Bot added the size/M Single-domain feat or fix with limited business impact label May 21, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 22, 2026

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add leeguooooo/cli#fix/classify-wiki-lock-contention -y -g

@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.76%. Comparing base (4582dfd) to head (ae3d352).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1014   +/-   ##
=======================================
  Coverage   67.76%   67.76%           
=======================================
  Files         590      590           
  Lines       55194    55196    +2     
=======================================
+ Hits        37400    37402    +2     
  Misses      14682    14682           
  Partials     3112     3112           

☔ View full report in Codecov by Sentry.
📢 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.

@fangshuyu-768
Copy link
Copy Markdown
Collaborator

CI lint is failing because this branch was cut from an older main where shortcuts/sheets/lark_sheets_cell_images.go had a depguard violation (internal/vfs import). That violation has already been fixed on main.

A rebase onto the latest main should resolve the lint failure:

git fetch origin main
git rebase origin/main
git push --force-with-lease

…hint

Wiki write-path operations (most commonly `wiki +node-create` against the
same parent) surface code 131009 "lock contention" under concurrent calls.
Currently this falls through to the generic "api_error" classification,
giving users no hint that it is transient and safe to retry.

Mirror the existing `LarkErrDriveResourceContention` (1061045) treatment:
add a named constant, classify as "conflict", and emit a hint that points
the caller toward exponential backoff or serializing sibling-node writes.

Refs: larksuite#1012
@leeguooooo leeguooooo force-pushed the fix/classify-wiki-lock-contention branch from 52e0ce4 to ae3d352 Compare May 22, 2026 10:33
@leeguooooo
Copy link
Copy Markdown
Author

Done — rebased onto latest upstream/main (52e0ce4ae3d352), zero conflicts.

Verified locally with the same lint invocation CI uses:

go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.1.6 run --new-from-rev=upstream/main
# 0 issues.

The depguard violation in shortcuts/sheets/lark_sheets_cell_images.go is gone from the rebase since the fix is already on main. Force-pushed with --force-with-lease. CI should be green now.

Thanks for the quick turnaround review @fangshuyu-768!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Single-domain feat or fix with limited business impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants