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
    • Enhanced error handling for wiki write operations experiencing lock contention, with improved retry guidance to resolve conflicts automatically.

Review Change Stack

…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
@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: ed528406-43c6-446e-87b7-dd0c8610e7c2

📥 Commits

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

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

📝 Walkthrough

Walkthrough

This PR adds support for handling a transient Lark API error that occurs during concurrent wiki writes. A new error constant is defined, the error classification function is extended to recognize it as a retryable conflict, and test coverage validates the expected behavior.

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
The LarkErrWikiLockContention constant maps to error code 131009. ClassifyLarkError recognizes this code and returns ExitAPI with "conflict" type and a hint guiding retry and backoff for write-lock contention. A test validates the classification, exit code, type, and hint messaging.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A wiki's locks now dance with grace,
When writes collide in cyberspace—
Backoff and retry, never fear,
The conflict fades, the path is clear!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding classification for wiki lock-contention error 131009 with a retry hint.
Description check ✅ Passed The description comprehensively covers all required template sections with clear motivation, specific changes, validated test plan, and relevant issue references.
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
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.

2 participants