Skip to content

fix(wiki): reuse 131006 terminal guidance on copy and move - #2349

Open
ViperCai wants to merge 1 commit into
mainfrom
fix/wiki-copy-move-permission-guidance
Open

fix(wiki): reuse 131006 terminal guidance on copy and move#2349
ViperCai wants to merge 1 commit into
mainfrom
fix/wiki-copy-move-permission-guidance

Conversation

@ViperCai

@ViperCai ViperCai commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

wiki +node-get already treats Wiki 131006 as a terminal resource-access error. wiki +node-copy and wiki +move still returned the generic permission hint, so agents could keep retrying the same copy/move after a node or parent ACL failure.

Changes

  • Extract shared annotateWikiPermissionDenied for Wiki 131006.
  • Apply it to wiki +node-copy and wiki +move (including move-time get_node resolve).
  • Route +node-get / +node-list through the same helper so the hint stays in one place.
  • Add revert-failing tests and document the recovery rule in the copy/move skill references.

Test Plan

  • go test ./shortcuts/wiki -count=1
  • Manual local verification confirms the lark-cli wiki +node-copy / lark-cli wiki +move 131006 flow works as expected

Related Issues

  • None

Summary by CodeRabbit

  • Bug Fixes

    • Improved Wiki copy and move error handling with operation-specific permission guidance.
    • Permission-denied errors now identify the required access and are not retried unnecessarily.
    • Asynchronous move tasks stop polling immediately when resource permissions are insufficient.
    • Preserved existing handling for unrelated errors and prevented duplicate guidance.
  • Documentation

    • Added guidance for resolving resource permission errors during Wiki moves and copies.
    • Clarified access requirements for node moves, Docs-to-Wiki operations, and task-status updates.

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

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

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: 023215ec-427f-40c2-b535-27655ebaff54

📥 Commits

Reviewing files that changed from the base of the PR and between 469f828 and 336e39d.

📒 Files selected for processing (1)
  • skills/lark-wiki/references/lark-wiki-move.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • skills/lark-wiki/references/lark-wiki-move.md

📝 Walkthrough

Walkthrough

Wiki permission handling now classifies error 131006 as terminal, adds operation-specific recovery hints, preserves causes, and stops task polling immediately. Wiki copy, move, lookup, and Docs-to-Wiki paths use the new annotations with expanded tests and documentation.

Changes

Wiki permission-denied handling

Layer / File(s) Summary
Centralized permission annotation
shortcuts/wiki/wiki_helpers.go, shortcuts/wiki/wiki_helpers_test.go
The shared classifier recognizes 131006, marks it non-retryable, preserves causes, avoids duplicate hints, and selects operation-specific recovery guidance.
Operation propagation and polling
shortcuts/wiki/wiki_node_copy.go, shortcuts/wiki/wiki_move.go
Wiki copy, lookup, node move, Docs-to-Wiki, and task-status paths apply the corresponding annotations. Permission failures terminate asynchronous polling without retries.
Operation validation and documentation
shortcuts/wiki/wiki_list_copy_test.go, shortcuts/wiki/wiki_move_test.go, skills/lark-wiki/references/*
Tests cover permission classification, hints, polling termination, and retry behavior. Wiki references describe resource-permission handling for move and copy operations.

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

Merge Risk: ⚪ Minimal · up to 336e3

The PR centralizes terminal permission guidance for Wiki copy and move operations and adds tests and documentation; no actionable merge-blocking risk remains beyond normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant WikiOperation
  participant WikiAPI
  participant PermissionAnnotation
  participant TaskPoller
  WikiOperation->>WikiAPI: Execute Wiki operation
  WikiAPI-->>WikiOperation: Return error 131006
  WikiOperation->>PermissionAnnotation: Apply operation-specific hint
  PermissionAnnotation-->>WikiOperation: Return terminal annotated error
  TaskPoller->>PermissionAnnotation: Classify task permission error
  PermissionAnnotation-->>TaskPoller: Stop polling without retry
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.59% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the Wiki fix and the reuse of terminal guidance for error 131006 across copy and move operations.
Description check ✅ Passed The description includes the required summary, changes, test plan, and related issues sections, and clearly notes that manual verification remains pending.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/wiki-copy-move-permission-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 14, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add larksuite/cli#fix/wiki-copy-move-permission-guidance -y -g

@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.44%. Comparing base (0a20372) to head (336e39d).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2349      +/-   ##
==========================================
+ Coverage   76.35%   76.44%   +0.08%     
==========================================
  Files        1043     1046       +3     
  Lines      114771   115134     +363     
==========================================
+ Hits        87638    88016     +378     
+ Misses      20385    20366      -19     
- Partials     6748     6752       +4     

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

Comment thread shortcuts/wiki/wiki_helpers.go Outdated
@ViperCai
ViperCai force-pushed the fix/wiki-copy-move-permission-guidance branch from dc3816e to d3ec09e Compare August 14, 2026 08:53
Comment thread shortcuts/wiki/wiki_helpers.go Outdated
// on the relevant parent nodes; copying or moving to a space root can also
// require wiki space membership or administrator permission.
func wikiWritePermissionDeniedHint() string {
return "The current user or app/bot identity lacks Wiki container permission for this write. This is resource access, not app scope authorization. Do not retry the same request, reauthorize, or switch identity as trial and error; ask the resource owner or wiki administrator to grant container edit permission on the relevant source or destination parent node. Copying or moving to a space root can also require wiki space membership or administrator permission. Use an accessible resource if that access cannot be granted."

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Keep write recovery specific to each move mode

This hint is shared by node copy, Wiki node move, and docs-to-wiki, but those 131006 cases do not share one resource-permission set. The official node-move contract requires edit permission on the moved node in addition to source and destination parent-container edit permission. For docs-to-wiki, 131006 can instead mean that the source Drive document lacks manage permission or its parent folder lacks edit permission. Following the current Wiki-container-only hint can therefore leave these cases unresolved even after the requested grant. Please use operation-specific hints, or include the moved-node and source-Drive requirements in the relevant paths.

References: https://open.feishu.cn/document/server-docs/docs/wiki-v2/space-node/move and https://open.feishu.cn/document/server-docs/docs/wiki-v2/task/get?lang=zh-CN

Comment thread shortcuts/wiki/wiki_move.go Outdated
)
if err != nil {
return nil, err
return nil, annotateWikiWritePermissionDenied(err)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Treat 131006 from task polling as terminal

After this call returns a task_id, the GetMoveTask endpoint can itself return 131006. GetMoveTask currently returns that error without the new annotation, and pollWikiMoveTask unconditionally treats every poll error as transient, so the command makes all 30 attempts and finally tells the caller to retry status lookup. That contradicts the new terminal no-retry contract. Please annotate 131006 on the task-result path and short-circuit polling before the next attempt, with recovery appropriate to the documented task permission failure.

Reference: https://open.feishu.cn/document/server-docs/docs/wiki-v2/task/get?lang=zh-CN

@ViperCai
ViperCai force-pushed the fix/wiki-copy-move-permission-guidance branch 2 times, most recently from 461132e to 469f828 Compare August 14, 2026 09:46
wiki +node-get already treats 131006 as a non-retryable resource-access
error. Apply the same terminal classification to +node-copy and +move,
with path-specific recovery: copy uses parent container edit, node move
also needs edit on the moved node, and docs-to-wiki can require Drive
manage plus parent-folder edit. Treat task-lookup 131006 as terminal
instead of polling it 30 times. Keep the existing read-access hint on
get/list and on move's get_node resolve.
@ViperCai
ViperCai force-pushed the fix/wiki-copy-move-permission-guidance branch from 469f828 to 336e39d Compare August 14, 2026 10:34
// requires container edit on the source or destination parent; a space-root
// target can also require wiki space membership or administrator permission.
func wikiCopyPermissionDeniedHint() string {
return "The current user or app/bot identity lacks Wiki container permission for this copy. This is resource access, not app scope authorization. Do not retry the same request, reauthorize, or switch identity as trial and error; ask the resource owner or wiki administrator to grant container edit permission on the relevant source or destination parent node. Copying to a space root can also require wiki space membership or administrator permission. Use an accessible resource if that access cannot be granted."

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Include source-node access in copy recovery

The mounted regression for this path explicitly models 131006 as node permission denied, user needs read permission, but this hint only asks for container edit permission on source or destination parents, and the test rejects any read-access guidance. If the caller cannot read the source node, granting parent-container edit access does not make that source copyable, so the terminal error still directs the owner to a recovery that cannot fix the request. Because 131006 conflates source-node and destination-container ACL failures and this code intentionally does not branch on the unstable message text, please make the stable copy hint cover source-node read or copy access as well as destination-parent container edit, or keep it permission-neutral.

Reference: https://open.feishu.cn/document/server-docs/docs/wiki-v2/space-node/copy?lang=zh-CN

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.

2 participants