feat(base): auto grant current user for bot create and copy#497
feat(base): auto grant current user for bot create and copy#497zgz2048 merged 6 commits intolarksuite:mainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughSplit shortcut auth scopes into Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant CLI as CLI Shortcut
participant BaseAPI as Base API
participant PermAPI as Permissions API
User->>CLI: Run base create/copy (bot auth)
CLI->>BaseAPI: Call base create/copy endpoint
BaseAPI-->>CLI: Respond with base data (includes base_token/app_token)
alt Bot has current user OpenID
CLI->>PermAPI: Attempt grant full_access to current user
alt Grant succeeds
PermAPI-->>CLI: Grant confirmed
CLI->>CLI: permission_grant.status = "granted"
else Grant fails
PermAPI-->>CLI: Grant failed
CLI->>CLI: permission_grant.status = "failed"
end
else No current user OpenID
CLI->>CLI: permission_grant.status = "skipped"
end
CLI-->>User: Return response containing base and permission_grant
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@da07b1e815e37f106b59b664ffa84fe44c57ebe1🧩 Skill updatenpx skills add zgz2048/cli#feat/base-auto-grant-current-user -y -g |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@shortcuts/base/base_copy.go`:
- Line 17: Remove the auto-grant scope "docs:permission.member:create" from the
Scopes list in the shortcut declaration (the Scopes slice in base_copy.go) so
normal user-mode (--as user) copies don't require it, and instead ensure the
bot-only grant logic in shortcuts/base/base_ops.go (the code path that executes
when running as bot) adds or requests "docs:permission.member:create" as part of
its auth/grant flow; in short: delete the extra scope from the Scopes array in
base_copy.go and attach/request that scope only within the bot-auth grant logic
in base_ops.go.
In `@shortcuts/base/base_create.go`:
- Line 17: The Scopes array on the shortcut (Scopes in base_create.go for the
+base-create shortcut) wrongly includes "docs:permission.member:create" which
broadens user auth even though augmentBasePermissionGrant (in base_ops.go) only
grants that scope in bot mode (guarded by runtime.IsBot()); remove
"docs:permission.member:create" from the Scopes slice so user (--as user) flows
don't request it, and ensure the existing augmentBasePermissionGrant function
continues to add that scope only in the bot-only path (runtime.IsBot()) where
it's needed.
In `@shortcuts/base/base_ops.go`:
- Around line 24-26: The dry-run guidance emitted inside the runtime.IsBot()
conditional is currently using d.Desc(...), which writes to stdout; change those
calls (the d.Desc(...) at runtime.IsBot() and the similar calls around lines
34-36) so the hint is written to stderr instead—e.g., replace the d.Desc(...)
usage with an explicit write to os.Stderr (using fmt.Fprintln/os.Stderr or the
codebase's stderr helper) so runtime.IsBot() hints go to stderr and stdout
remains machine-readable.
🪄 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: 80dc2a49-3e0b-48dc-a9a9-ce92c50a1922
📒 Files selected for processing (7)
shortcuts/base/base_copy.goshortcuts/base/base_create.goshortcuts/base/base_execute_test.goshortcuts/base/base_ops.goskills/lark-base/SKILL.mdskills/lark-base/references/lark-base-base-copy.mdskills/lark-base/references/lark-base-base-create.md
Co-authored-by: kongenpei <kongenpei.jojo@bytedance.com>
Co-authored-by: kongenpei <kongenpei.jojo@bytedance.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #497 +/- ##
=======================================
Coverage ? 59.06%
=======================================
Files ? 384
Lines ? 32645
Branches ? 0
=======================================
Hits ? 19282
Misses ? 11555
Partials ? 1808 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
base +base-createandbase +base-copypermission_grantresults and keep user-mode behavior unchangedTesting
Summary by CodeRabbit
New Features
granted,skipped, orfailed) in output.Documentation
Bug Fixes