Skip to content

fix(vc): align meeting query scopes by identity#1850

Merged
zhicong666-bytedance merged 38 commits into
mainfrom
feat/lark-cli-vc-meeting-query-dual-scope-narrow
Jul 15, 2026
Merged

fix(vc): align meeting query scopes by identity#1850
zhicong666-bytedance merged 38 commits into
mainfrom
feat/lark-cli-vc-meeting-query-dual-scope-narrow

Conversation

@zhicong666-bytedance

@zhicong666-bytedance zhicong666-bytedance commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

This change aligns VC meeting query shortcuts with the actual permission model used by the upstream APIs. Instead of relying on framework-level identity scope lists, +meeting-list-active and +meeting-events now perform VC-local validation so either vc:meeting.meetingevent:read or vc:meeting.bot.join:write can satisfy the local preflight without changing shared framework behavior.

Changes

  • Add a shared VC helper for command-local "any of these scopes" validation
  • Remove framework-declared UserScopes and BotScopes from +meeting-list-active and +meeting-events
  • Invoke the VC-local scope check from both commands' Validate paths
  • Update VC tests to verify the commands no longer depend on framework AND-style scope preflight and accept either supported scope

Test Plan

  • Unit tests pass
  • Manual local verification confirms the lark-cli vc flow works as expected
  • go test ./shortcuts/vc
  • Verified vc +meeting-list-active --as user succeeds when vc:meeting.meetingevent:read is granted and returns an active meeting meeting_id
  • Verified vc +meeting-list-active --as bot --user-id <user_open_id> succeeds when vc:meeting.meetingevent:read is available to the meeting query flow
  • Verified vc +meeting-list-active --as bot --user-id <user_open_id> succeeds when vc:meeting.bot.join:write is available to the meeting query flow
  • Verified vc +meeting-events --as bot --meeting-id <meeting_id> reaches the remote API without a local missing_scope failure when vc:meeting.meetingevent:read is available; before the bot joined the meeting, the API returned bot is not in the meeting
  • Verified vc +meeting-join --as bot --meeting-number <meeting_no> succeeds after vc:meeting.bot.join:write is applied
  • Verified vc +meeting-events --as bot --meeting-id <meeting_id> succeeds after the bot joins the meeting and returns meeting activity events

Related Issues

  • None

Summary by CodeRabbit

  • New Features
    • Meeting event and active-meeting commands now perform an explicit “any supported permission” pre-check (user event read or bot join write).
    • If resolvable scopes don’t match, authorization errors now list the accepted scope options and include login guidance.
  • Documentation
    • Added identity-specific permission recommendations for meeting events and active-meeting commands (user vs bot).
  • Tests
    • Added unit tests covering any-scope acceptance/rejection and lenient behavior when local scope information is unavailable.

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

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

Meeting event and active-meeting shortcuts now validate runtime authorization using either supported meeting-query scope. Static scope metadata, validation logic, tests, and identity-specific permission guidance were updated.

Changes

VC meeting scope validation

Layer / File(s) Summary
Meeting query scope checker
shortcuts/vc/helpers.go, shortcuts/vc/helpers_test.go
Defines candidate scopes, resolves token scope data, returns missing-scope errors when no candidate matches, and tests successful, failing, and unavailable resolution.
Shortcut validation integration
shortcuts/vc/vc_meeting_events.go, shortcuts/vc/vc_meeting_list_active.go, shortcuts/vc/*_test.go
Replaces static scopes with runtime any-scope validation and tests accepted scope combinations.
Identity-specific permission guidance
skills/lark-vc-agent/references/lark-vc-agent-meeting-*.md
Documents recommended permissions for user and bot identities.

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

Sequence Diagram(s)

sequenceDiagram
  participant VCMeetingShortcut
  participant checkMeetingQueryAnyScope
  participant meetingQueryTokenResolver
  participant PermissionError
  VCMeetingShortcut->>checkMeetingQueryAnyScope: validate meeting query access
  checkMeetingQueryAnyScope->>meetingQueryTokenResolver: resolve identity and granted scopes
  checkMeetingQueryAnyScope->>PermissionError: return missing-scope error when no candidate matches
Loading

Possibly related PRs

  • larksuite/cli#824: Introduces the VCMeetingEvents shortcut whose scope and validation behavior are updated here.

Suggested reviewers: zhaoleibd, calendar-assistant

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.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 accurately summarizes the main change: aligning meeting query scopes by identity.
Description check ✅ Passed The description matches the template with Summary, Changes, Test Plan, and Related Issues sections filled out.
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/lark-cli-vc-meeting-query-dual-scope-narrow

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.

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

🧹 Nitpick comments (2)
shortcuts/vc/vc_meeting_events_test.go (1)

421-437: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add an error-path test for checkMeetingQueryAnyScope.

The new test verifies ScopesForIdentity returns empty and hasAnyGrantedScope accepts/rejects the right scopes, but doesn't exercise the checkMeetingQueryAnyScope error path — where no candidate scope is granted and the function returns a typed *errs.PermissionError. Per coding guidelines, error-path tests must assert typed metadata via errs.ProblemOf (category / subtype / param) and cause preservation.

Consider adding a test that constructs a RuntimeContext with a credential provider returning a token with no meeting-query scopes, calls checkMeetingQueryAnyScope, and asserts the returned error is a *errs.PermissionError with Category == errs.CategoryAuthorization, Subtype == errs.SubtypeMissingScope, and populated MissingScopes / Identity / Hint.

🤖 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/vc/vc_meeting_events_test.go` around lines 421 - 437, Add an
error-path test for checkMeetingQueryAnyScope that builds a RuntimeContext whose
credential provider returns a token without meeting-query scopes, then invokes
the check directly. Assert the error via errs.ProblemOf and verify it is a
*errs.PermissionError with Category authorization, Subtype missing-scope,
populated MissingScopes, Identity, and Hint, while also confirming the
underlying cause is preserved.

Source: Coding guidelines

shortcuts/vc/vc_meeting_test.go (1)

611-627: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Same error-path test gap applies here.

The hasAnyGrantedScope assertions in this test are identical to those in TestMeetingEvents_UsesCustomAnyScopeCheck — they verify the shared helper rather than VCMeetingListActive-specific behavior. The same suggestion to add an error-path test for checkMeetingQueryAnyScope applies. If a shared test for the helper is added (e.g., in a helpers_test.go), the duplicated hasAnyGrantedScope assertions could be removed from both shortcut test files.

🤖 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/vc/vc_meeting_test.go` around lines 611 - 627, Update
TestMeetingListActive_UsesCustomAnyScopeCheck to cover the error path of
checkMeetingQueryAnyScope, verifying errors are returned or handled correctly
for invalid scope input. Move the shared hasAnyGrantedScope assertions into a
dedicated helper test (such as helpers_test.go) and remove the duplicated
assertions from this test and TestMeetingEvents_UsesCustomAnyScopeCheck.

Source: Coding guidelines

🤖 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-vc-agent/references/lark-vc-agent-meeting-events.md`:
- Around line 16-21: Clarify the permissions table in the meeting-events
documentation: the listed scopes are recommendations, not identity-exclusive
requirements. State that runtime authorization in the relevant
permission-checking helper accepts either vc:meeting.meetingevent:read or
vc:meeting.bot.join:write for both --as user and --as bot.
- Around line 18-21: Replace the unexplained “UAT” and “TAT” labels in the
permissions table with the documented identity names “用户身份” and “应用身份,” while
retaining the corresponding --as user and --as bot examples and permission
values.

In `@skills/lark-vc-agent/references/lark-vc-agent-meeting-list-active.md`:
- Around line 11-14: Remove the unexplained “UAT” and “TAT” abbreviations from
the permissions table, using “用户身份” and “应用身份” consistently in the scenario
labels while preserving the existing command references and permission
recommendations.
- Around line 9-14: Update the permissions table in the meeting-list
documentation to state that both listed scopes are supported for either identity
(`--as user` and `--as bot`), while retaining the current scopes as
recommendations. Clarify that the command is authorized when either candidate
scope is granted, and avoid implying that each identity requires only its
corresponding scope.

---

Nitpick comments:
In `@shortcuts/vc/vc_meeting_events_test.go`:
- Around line 421-437: Add an error-path test for checkMeetingQueryAnyScope that
builds a RuntimeContext whose credential provider returns a token without
meeting-query scopes, then invokes the check directly. Assert the error via
errs.ProblemOf and verify it is a *errs.PermissionError with Category
authorization, Subtype missing-scope, populated MissingScopes, Identity, and
Hint, while also confirming the underlying cause is preserved.

In `@shortcuts/vc/vc_meeting_test.go`:
- Around line 611-627: Update TestMeetingListActive_UsesCustomAnyScopeCheck to
cover the error path of checkMeetingQueryAnyScope, verifying errors are returned
or handled correctly for invalid scope input. Move the shared hasAnyGrantedScope
assertions into a dedicated helper test (such as helpers_test.go) and remove the
duplicated assertions from this test and
TestMeetingEvents_UsesCustomAnyScopeCheck.
🪄 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: 8c7cb651-60cd-4255-852d-b4039612ae9b

📥 Commits

Reviewing files that changed from the base of the PR and between 0dd844c and 1b7a2e4.

📒 Files selected for processing (7)
  • shortcuts/vc/helpers.go
  • shortcuts/vc/vc_meeting_events.go
  • shortcuts/vc/vc_meeting_events_test.go
  • shortcuts/vc/vc_meeting_list_active.go
  • shortcuts/vc/vc_meeting_test.go
  • skills/lark-vc-agent/references/lark-vc-agent-meeting-events.md
  • skills/lark-vc-agent/references/lark-vc-agent-meeting-list-active.md

Comment thread skills/lark-vc-agent/references/lark-vc-agent-meeting-events.md Outdated
Comment thread skills/lark-vc-agent/references/lark-vc-agent-meeting-events.md Outdated
Comment thread skills/lark-vc-agent/references/lark-vc-agent-meeting-list-active.md Outdated
Comment thread skills/lark-vc-agent/references/lark-vc-agent-meeting-list-active.md Outdated
@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add larksuite/cli#feat/lark-cli-vc-meeting-query-dual-scope-narrow -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/vc/helpers_test.go`:
- Around line 43-68: Add a `Category` assertion in
`assertMeetingQueryPermissionError` alongside the existing `Subtype` validation,
comparing `pe.Category` against the expected permission-error category constant
used by the surrounding tests or error definitions. Keep the existing
`errors.As`-based `PermissionError` checks and metadata validations intact.
🪄 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: 1ebe58ac-cf30-4420-bbc2-739b1b45145f

📥 Commits

Reviewing files that changed from the base of the PR and between 1b7a2e4 and 62f8b56.

📒 Files selected for processing (2)
  • shortcuts/vc/helpers.go
  • shortcuts/vc/helpers_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • shortcuts/vc/helpers.go

Comment thread shortcuts/vc/helpers_test.go Outdated
@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.73%. Comparing base (e96c4fa) to head (f57d98c).
⚠️ Report is 27 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1850      +/-   ##
==========================================
+ Coverage   74.58%   74.73%   +0.14%     
==========================================
  Files         861      887      +26     
  Lines       89971    92644    +2673     
==========================================
+ Hits        67106    69235    +2129     
- Misses      17669    18050     +381     
- Partials     5196     5359     +163     

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

@zhicong666-bytedance
zhicong666-bytedance force-pushed the feat/lark-cli-vc-meeting-query-dual-scope-narrow branch from 8049df1 to f83ee72 Compare July 13, 2026 04:33
@zhicong666-bytedance
zhicong666-bytedance force-pushed the feat/lark-cli-vc-meeting-query-dual-scope-narrow branch from f83ee72 to 20ea90e Compare July 13, 2026 06:18
@zhicong666-bytedance
zhicong666-bytedance force-pushed the feat/lark-cli-vc-meeting-query-dual-scope-narrow branch from f0f280e to a56dda9 Compare July 14, 2026 10:09
zhaoleibd
zhaoleibd previously approved these changes Jul 15, 2026
@zhicong666-bytedance
zhicong666-bytedance merged commit 64caef1 into main Jul 15, 2026
25 checks passed
@zhicong666-bytedance
zhicong666-bytedance deleted the feat/lark-cli-vc-meeting-query-dual-scope-narrow branch July 15, 2026 11:40
@liangshuo-1 liangshuo-1 mentioned this pull request Jul 15, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain/vc PR touches the vc 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.

2 participants