Skip to content

feat(drive): add permission get setting shortcut#1775

Open
zhaojiaxing-coding wants to merge 4 commits into
mainfrom
feat/drive-permission-get-setting
Open

feat(drive): add permission get setting shortcut#1775
zhaojiaxing-coding wants to merge 4 commits into
mainfrom
feat/drive-permission-get-setting

Conversation

@zhaojiaxing-coding

@zhaojiaxing-coding zhaojiaxing-coding commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add the drive +permission-get-setting shortcut to read Drive public permission settings for supported file types.

Changes

  • Support reading public permission settings by URL.
  • Support reading public permission settings by token plus --type.

Related Issues

  • None

Summary by CodeRabbit

  • New Features
    • Added the Drive shortcut +permission-get-setting to fetch a node’s own permission_public settings (token or supported Drive/document URLs; requires --type for bare tokens; non-recursive/readonly) with streamlined JSON output.
    • Supports DryRun to preview the generated GET /open-apis/drive/v2/permissions/{token}/public request details.
  • Bug Fixes
    • Improved --token/--type parsing and validation, including clearer typed validation failures and safer handling of mismatched/unsupported URL forms.
  • Documentation
    • Updated Drive permission governance workflow and references to use +permission-get-setting, including folder-specific guidance and wording consistency.
  • Tests
    • Added unit and end-to-end coverage for spec resolution, dry-run, execution output, and shortcut registration.

@github-actions github-actions Bot added domain/ccm PR touches the ccm domain size/L Large or sensitive change across domains or core paths labels Jul 7, 2026
@coderabbitai

coderabbitai Bot commented Jul 7, 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
📝 Walkthrough

Walkthrough

This PR adds the +permission-get-setting Drive shortcut for reading permission_public settings from supported targets, registers it, adds unit and CLI end-to-end coverage, and updates Drive skill and permission-governance documentation.

Changes

Drive Permission Get Setting

Layer / File(s) Summary
Core shortcut implementation
shortcuts/drive/drive_permission_get_setting.go
Adds token/type validation, URL inference, permission endpoint requests, response normalization, and Validate/DryRun/Execute handlers.
Shortcut registration and validation coverage
shortcuts/drive/shortcuts.go, shortcuts/drive/shortcuts_test.go, shortcuts/drive/drive_permission_get_setting_test.go
Registers the command and tests resolution, validation errors, dry-run requests, output shape, and authorization metadata.
CLI end-to-end coverage
tests/cli_e2e/drive/drive_permission_get_setting_test.go
Tests dry-run request generation and live permission_public output for a Drive folder.
Permission governance workflow alignment
skills/lark-drive/references/lark-drive-workflow-permission-governance*.md, skills/lark-drive/references/lark-drive-workflow-permission-governance-outputs.md
Replaces prior permission-read guidance, updates folder handling and verification rules, and revises related output terminology and rollback wording.
Shortcut skill documentation
skills/lark-drive/SKILL.md, skills/lark-drive/references/lark-drive-permission-get-setting.md
Documents supported inputs, output, non-recursive behavior, parameters, boundaries, and common errors.

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

Possibly related PRs

  • larksuite/cli#1292: Updates permission-governance workflow guidance to use drive +permission-get-setting for permission reads and verification.

Suggested labels: documentation

Suggested reviewers: fangshuyu-768

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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 is concise and clearly describes the main change: adding the drive permission-get-setting shortcut.
Description check ✅ Passed The description covers Summary, Changes, and Related Issues, but it omits the required Test Plan section details.
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 feat/drive-permission-get-setting

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 Jul 7, 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

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add larksuite/cli#feat/drive-permission-get-setting -y -g

@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: 1

🤖 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/drive/drive_permission_get_setting.go`:
- Around line 82-84: The validation wrapping for drivePermissionGetSettingSpec
currently drops the original error from validate.ResourceName, so update both
error-return branches in the drivePermissionGetSetting logic to attach the
underlying err with WithCause(err) alongside the existing WithParam("--token").
Use the existing validate.ResourceName and errs.NewValidationError call sites so
callers can inspect the wrapped cause via errors.Is and errors.Unwrap.
🪄 Autofix (Beta)

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

Run ID: a1cd3cb7-adb2-47f3-9fa3-b2e3475e6eb1

📥 Commits

Reviewing files that changed from the base of the PR and between f0b6f35 and 33d18f5.

📒 Files selected for processing (9)
  • shortcuts/drive/drive_permission_get_setting.go
  • shortcuts/drive/drive_permission_get_setting_test.go
  • shortcuts/drive/shortcuts.go
  • shortcuts/drive/shortcuts_test.go
  • skills/lark-drive/SKILL.md
  • skills/lark-drive/references/lark-drive-workflow-permission-governance-commands.md
  • skills/lark-drive/references/lark-drive-workflow-permission-governance-outputs.md
  • skills/lark-drive/references/lark-drive-workflow-permission-governance.md
  • tests/cli_e2e/drive/drive_permission_get_setting_test.go

Comment on lines +82 to +84
if err := validate.ResourceName(ref.Token, "--token"); err != nil {
return drivePermissionGetSettingSpec{}, errs.NewValidationError(errs.SubtypeInvalidArgument, "%s", err).WithParam("--token")
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Inspect validate.ResourceName's implementation and return type.
ast-grep outline internal/validate --items all --match 'ResourceName' --view expanded
rg -nP -A8 'func ResourceName\(' internal/validate

Repository: larksuite/cli

Length of output: 976


Preserve the underlying validation error when wrapping validate.ResourceName failures. Add .WithCause(err) in both branches so callers can inspect the original error with errors.Is / errors.Unwrap.

🤖 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 `@shortcuts/drive/drive_permission_get_setting.go` around lines 82 - 84, The
validation wrapping for drivePermissionGetSettingSpec currently drops the
original error from validate.ResourceName, so update both error-return branches
in the drivePermissionGetSetting logic to attach the underlying err with
WithCause(err) alongside the existing WithParam("--token"). Use the existing
validate.ResourceName and errs.NewValidationError call sites so callers can
inspect the wrapped cause via errors.Is and errors.Unwrap.

Source: Coding guidelines

@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: 1

🤖 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 `@skills/lark-drive/references/lark-drive-permission-get-setting.md`:
- Line 75: The markdown table row in the permission setting reference is being
split into extra columns because the type examples use unescaped pipes. Update
the row in the document content so the `docx|folder|file|...` text is escaped or
rewritten as a list, keeping the table structure intact and ensuring the error
message renders correctly.
🪄 Autofix (Beta)

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

Run ID: 39c779c0-4948-409c-9c68-3434f8652e5f

📥 Commits

Reviewing files that changed from the base of the PR and between 33d18f5 and 990bd48.

📒 Files selected for processing (1)
  • skills/lark-drive/references/lark-drive-permission-get-setting.md

| 症状 | 原因 | 处理 |
|------|------|------|
| `--token is required` | 没传目标 | 传目标 URL 或裸 token。 |
| `--type is required when --token is a bare token` | 裸 token 无法自动推断类型 | 补充 `--type docx|folder|file|...`。 |

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Escape the pipes in the error table row.

docx|folder|file|... is being parsed as extra markdown columns, so this row will render incorrectly and drop part of the message. Use escaped pipes or rewrite the value as a list.

Suggested fix
-| `--type ...` | 裸 token 无法自动推断类型 | 补充 `--type docx|folder|file|...`。 |
+| `--type ...` | 裸 token 无法自动推断类型 | 补充 `--type docx&`#124`;folder&`#124`;file&`#124`;...`。 |
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
| `--type is required when --token is a bare token` | 裸 token 无法自动推断类型 | 补充 `--type docx|folder|file|...`。 |
| `--type is required when --token is a bare token` | 裸 token 无法自动推断类型 | 补充 `--type docx&`#124`;folder&`#124`;file&`#124`;...`|
🧰 Tools
🪛 markdownlint-cli2 (0.22.1)

[warning] 75-75: Table column count
Expected: 3; Actual: 6; Too many cells, extra data will be missing

(MD056, table-column-count)

🤖 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-permission-get-setting.md` at line
75, The markdown table row in the permission setting reference is being split
into extra columns because the type examples use unescaped pipes. Update the row
in the document content so the `docx|folder|file|...` text is escaped or
rewritten as a list, keeping the table structure intact and ensuring the error
message renders correctly.

Source: Linters/SAST tools

@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.76106% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.69%. Comparing base (16a93cd) to head (669aac0).
⚠️ Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
shortcuts/drive/drive_permission_get_setting.go 78.57% 16 Missing and 8 partials ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main    #1775    +/-   ##
========================================
  Coverage   74.68%   74.69%            
========================================
  Files         878      879     +1     
  Lines       91786    92007   +221     
========================================
+ Hits        68554    68722   +168     
- Misses      17922    17957    +35     
- Partials     5310     5328    +18     

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

@zhaojiaxing-coding
zhaojiaxing-coding force-pushed the feat/drive-permission-get-setting branch from 9aaefa5 to c32fe2d Compare July 15, 2026 06:09
Add a read-only Drive shortcut for retrieving a resource's public access, sharing, collaborator management, security, and comment settings. It accepts supported Lark Drive URLs or explicitly typed bare tokens, returning actionable typed validation errors for invalid or conflicting inputs.

Key features:

- Query the Drive permission public endpoint for documents, files, wiki nodes, and folders

- Infer target type from supported URLs and require --type for bare tokens

- Register dry-run and validation coverage, including CLI end-to-end tests

- Document the command and its non-recursive folder behavior in the Drive skill
@zhaojiaxing-coding
zhaojiaxing-coding force-pushed the feat/drive-permission-get-setting branch from c32fe2d to c484d25 Compare July 15, 2026 06:12
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/L Large or sensitive change across domains or core paths

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant