Skip to content

feat: support bot identity for search shortcuts - #2194

Merged
BytedanceSearch merged 4 commits into
larksuite:mainfrom
arnold9672:feat/search-tat-bot-identity
Aug 6, 2026
Merged

feat: support bot identity for search shortcuts#2194
BytedanceSearch merged 4 commits into
larksuite:mainfrom
arnold9672:feat/search-tat-bot-identity

Conversation

@arnold9672

@arnold9672 arnold9672 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

sa: safe
doc: skills/lark-im, skills/lark-minutes
cfg: none
test: unit test, dry-run e2e, live TAT smoke

Summary

  • Support bot identity for im +messages-search and minutes +search so TAT calls can pass CLI identity checks.
  • Update strict-mode and plugin-policy tests, shortcut metadata, dry-run e2e tests, and related IM/Minutes skill docs.

Verification

  • git diff --check origin/main..HEAD
  • go test ./shortcuts/im ./shortcuts/minutes ./cmd -run 'TestImMessagesSearch|TestMinutesSearch|TestIntegration_StrictModeBot_ProfileOverride'\n- go test ./tests/plugin_e2e -run 'TestLegacyRestrictReasonCodesRemainVisible|TestIdentityMismatchDenial'\n- LARK_CLI_BIN=/Users/jiahongnan/goworkspace/src/github.com/larksuite/cli/.harness_local/lark-cli-test go test ./tests/cli_e2e/im ./tests/cli_e2e/minutes -run 'TestIMMessagesSearchDryRunSupportsUserAndBotIdentity|TestMinutesSearchDryRunSupportsUserAndBotIdentity'\n- Live TAT smoke with test app: message search and minutes search returned ok=true, identity=bot.

Summary by CodeRabbit

  • New Features

    • Message search now supports both user and bot identities.
    • Minutes search now supports both user and bot identities.
    • Bot searches support keyword queries, pagination, and bot-specific chat resolution.
    • Bot requests provide clearer validation for unsupported me filters.
  • Documentation

    • Updated search guidance and identity requirements for user and bot usage.
  • Tests

    • Added end-to-end dry-run coverage for user and bot searches.
    • Improved validation of generated requests and dry-run output.

sa: safe
doc: skills/lark-im, skills/lark-minutes
cfg: none
test: unit test, dry-run e2e, live TAT smoke
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

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: fed42d62-140b-4592-9c4c-2d337c9d4e9b

📥 Commits

Reviewing files that changed from the base of the PR and between 34ddb5b and f85424b.

📒 Files selected for processing (6)
  • shortcuts/im/im_messages_search.go
  • shortcuts/im/im_messages_search_execute_test.go
  • shortcuts/minutes/minutes_search.go
  • shortcuts/minutes/minutes_search_test.go
  • skills/lark-im/references/lark-im-messages-search.md
  • tests/cli_e2e/minutes/minutes_search_dryrun_test.go
💤 Files with no reviewable changes (3)
  • shortcuts/minutes/minutes_search.go
  • shortcuts/im/im_messages_search_execute_test.go
  • shortcuts/minutes/minutes_search_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • skills/lark-im/references/lark-im-messages-search.md

📝 Walkthrough

Walkthrough

This PR enables bot identity support for IM message search and Minutes search. It updates shortcut metadata, dry-run and integration tests, identity-restriction coverage, dry-run JSON parsing, and product documentation for user and bot execution paths.

Changes

Search identity support

Layer / File(s) Summary
Search authentication contracts
shortcuts/im/im_messages_search.go, shortcuts/im/im_messages_search_execute_test.go, shortcuts/minutes/minutes_search.go, shortcuts/minutes/minutes_search_test.go
ImMessagesSearch and MinutesSearch now list both user and bot in AuthTypes. Tests assert both identities are present.
CLI and integration validation
cmd/root_integration_test.go, tests/cli_e2e/core.go, tests/cli_e2e/core_test.go, tests/cli_e2e/im/message_search_tat_dryrun_test.go, tests/cli_e2e/minutes/minutes_search_dryrun_test.go
Bot-mode help now keeps +messages-search visible. Dry-run parsing supports nested data.<path> values with root fallback. New dry-run tests validate IM and Minutes search requests for both identities.
Identity restriction coverage
tests/plugin_e2e/restrict_test.go
User-only identity restriction tests now use im +flag-list instead of im +messages-search. Comments and assertions now match static supported-identity checks.
Search identity documentation
skills/lark-im/SKILL.md, skills/lark-im/references/*, skills/lark-minutes/SKILL.md, skills/lark-minutes/references/lark-minutes-search.md
IM and Minutes docs now describe user and bot support. Minutes docs also clarify that me is user-only and bot searches must use explicit ou_ IDs, with separate permission guidance for each identity.

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

Possibly related PRs

  • larksuite/cli#2193: Both PRs change bot and user identity behavior, tests, and validation paths for IM shortcuts.
  • larksuite/cli#2186: Both PRs add "bot" support to search-related shortcut authentication contracts.
  • larksuite/cli#2138: Both PRs modify ImMessagesSearch behavior and its related test surface.

Suggested reviewers: liangshuo-1

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.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 clearly summarizes the main change: adding bot identity support for search shortcuts.
Description check ✅ Passed The description explains the scope and verification steps, although it uses a Verification section instead of the template's Changes and Test Plan sections.
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

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 added domain/im PR touches the im domain size/L Large or sensitive change across domains or core paths labels Aug 5, 2026

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

🤖 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-minutes/references/lark-minutes-search.md`:
- Around line 84-90: Update the permission and recovery guidance in the Lark
minutes search documentation to distinguish identities: recommend `lark-cli auth
login` only for user authentication and `me` resolution, while instructing bot
callers to verify the tenant access token and the application’s
`minutes:minutes.search:read` scope. Keep the existing user and bot
authentication behavior unchanged.

In `@tests/cli_e2e/im/message_search_tat_dryrun_test.go`:
- Around line 25-38: Add an assertion in the identity subtests for
tests/cli_e2e/im/message_search_tat_dryrun_test.go lines 25-38 and
tests/cli_e2e/minutes/minutes_search_dryrun_test.go lines 25-38 that the dry-run
identity field equals the loop’s identity value, using
clie2e.DryRunGet(result.Stdout, "identity").String() after validating the
command result.
🪄 Autofix

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 Plus

Run ID: 9630db48-84d5-469d-9bec-65354b72c56f

📥 Commits

Reviewing files that changed from the base of the PR and between 0848a5b and 8daec0e.

📒 Files selected for processing (13)
  • cmd/root_integration_test.go
  • shortcuts/im/im_messages_search.go
  • shortcuts/im/im_messages_search_execute_test.go
  • shortcuts/minutes/minutes_search.go
  • shortcuts/minutes/minutes_search_test.go
  • skills/lark-im/SKILL.md
  • skills/lark-im/references/lark-im-chat-messages-list.md
  • skills/lark-im/references/lark-im-messages-search.md
  • skills/lark-minutes/SKILL.md
  • skills/lark-minutes/references/lark-minutes-search.md
  • tests/cli_e2e/im/message_search_tat_dryrun_test.go
  • tests/cli_e2e/minutes/minutes_search_dryrun_test.go
  • tests/plugin_e2e/restrict_test.go

Comment thread skills/lark-minutes/references/lark-minutes-search.md
Comment thread tests/cli_e2e/im/message_search_tat_dryrun_test.go
@arnold9672

Copy link
Copy Markdown
Contributor Author

Validation update:

  • Live bot identity smoke passed for im +messages-search --query "激发创造": ok=true, identity=bot, 1 result.
  • Live bot identity smoke passed for minutes +search --query "妙记试试": ok=true, identity=bot, 1 result.
  • Live user identity smoke passed for im +messages-search --query "激发创造": ok=true, identity=user, 19 results.
  • Live user identity for minutes +search reached the expected user-scope gate; the current local user lacks minutes:minutes.search:read, so this is not a CLI regression.

sa: safe
doc: skills/lark-im
cfg: none
test: unit test, dry-run e2e

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
shortcuts/minutes/minutes_search.go (1)

246-249: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Clarify the bot filter help.

Bot identity is now supported, but the adjacent --owner-ids and --participant-ids help text still tells every caller to use "me". A bot call with that value fails validation. State that "me" is user-only and that bot calls require an explicit user open_id.

🤖 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/minutes/minutes_search.go` around lines 246 - 249, Update the help
text for the adjacent --owner-ids and --participant-ids options in the minutes
search command to clarify that "me" is valid only for user authentication, while
bot callers must provide an explicit user open_id. Keep the existing search
behavior and option definitions unchanged.
🤖 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/im/im_messages_search_execute_test.go`:
- Around line 256-285: The test TestImMessagesSearchWarnsOnChatEnrichmentFailure
currently fails the only chat batch and does not cover preservation of earlier
results. Update its fixtures to include more than chatBatchQuerySize distinct
chat IDs, return successful chat context for the first batch, fail the
subsequent batch, and assert the search output retains the first batch’s context
while stderr contains the enrichment warning.
- Around line 235-251: Update the error-path assertions in
shortcuts/im/im_messages_search_execute_test.go:235-251 and
shortcuts/minutes/minutes_search_test.go:231-244 to call errs.ProblemOf and
verify the expected category and subtype; in the minutes test, retain the
ValidationError.Param assertion, and in both tests assert the preserved cause
when provided. Keep errors.As for type-specific fields such as
PermissionError.Identity and ValidationError.Param.

In `@shortcuts/minutes/minutes_search.go`:
- Around line 96-98: Add table-driven coverage for the request-builder path by
invoking buildMinutesSearchBody or buildMinutesSearchFilter with a bot identity
and the "Me" value, and assert that it rejects the request directly. Keep the
existing MinutesSearch.Validate coverage, ensuring the new test verifies the
validation used by both DryRun and Execute paths.

In `@tests/cli_e2e/minutes/minutes_search_dryrun_test.go`:
- Around line 65-68: Expand the validation assertions in the minutes search
dry-run test to verify result.Stderr.error.type and result.Stderr.error.message
directly, and assert that result.Stdout is empty. Keep the existing subtype,
parameter, and hint checks, preserving the complete structured error envelope
and stdout behavior.

---

Outside diff comments:
In `@shortcuts/minutes/minutes_search.go`:
- Around line 246-249: Update the help text for the adjacent --owner-ids and
--participant-ids options in the minutes search command to clarify that "me" is
valid only for user authentication, while bot callers must provide an explicit
user open_id. Keep the existing search behavior and option definitions
unchanged.
🪄 Autofix

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 Plus

Run ID: beeffbd4-2912-4bdf-8392-927560db4e62

📥 Commits

Reviewing files that changed from the base of the PR and between 73e20af and 34ddb5b.

📒 Files selected for processing (7)
  • shortcuts/im/im_messages_search.go
  • shortcuts/im/im_messages_search_execute_test.go
  • shortcuts/minutes/minutes_search.go
  • shortcuts/minutes/minutes_search_test.go
  • skills/lark-im/references/lark-im-message-enrichment.md
  • skills/lark-im/references/lark-im-messages-search.md
  • tests/cli_e2e/minutes/minutes_search_dryrun_test.go

Comment thread shortcuts/im/im_messages_search_execute_test.go Outdated
Comment thread shortcuts/im/im_messages_search_execute_test.go Outdated
Comment thread shortcuts/minutes/minutes_search.go Outdated
Comment thread tests/cli_e2e/minutes/minutes_search_dryrun_test.go Outdated
@github-actions

github-actions Bot commented Aug 6, 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

  • license-header — cancelled — details
  • security — cancelled — details
  • fast-gate — cancelled — details
  • coverage — cancelled — details
  • script-test — cancelled — details
  • lint — cancelled — details
  • unit-test — cancelled — details
  • sidecar-integration — cancelled — details
  • deadcode — cancelled — details
  • e2e-dry-run — cancelled — details
  • plugin-integration — cancelled — details
  • deterministic-gate — cancelled — details
  • results — failure — details
  • e2e-live — cancelled — details

deterministic-gate

  • System issue: deterministic-gate failed, but quality-gate facts were unavailable. expected exactly one base-bound quality gate facts artifact, got 0

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add arnold9672/cli#feat/search-tat-bot-identity -y -g

@BytedanceSearch
BytedanceSearch self-requested a review August 6, 2026 02:57
@BytedanceSearch
BytedanceSearch merged commit b546516 into larksuite:main Aug 6, 2026
37 of 51 checks passed
liangshuo-1 added a commit that referenced this pull request Aug 6, 2026
#2194 extended `im +messages-search` to `AuthTypes: {user, bot}` but left the
affordance example and the skill reference asserting user-only, so the
dual-identity guard added by #2199 fails on main.

sa: safe
doc: affordance/im.md, skills/lark-im
cfg: none
test: go test -race ./cmd/... ./internal/... ./shortcuts/... ./extension/...
liangshuo-1 added a commit that referenced this pull request Aug 6, 2026
#2194 extended `im +messages-search` to `AuthTypes: {user, bot}` but left the
affordance example and the skill reference asserting user-only, so the
dual-identity guard added by #2199 fails on main.

sa: safe
doc: affordance/im.md, skills/lark-im
cfg: none
test: go test -race ./cmd/... ./internal/... ./shortcuts/... ./extension/...
YangJunzhou-01 pushed a commit that referenced this pull request Aug 6, 2026
#2194 extended `im +messages-search` to `AuthTypes: {user, bot}` but left the
affordance example and the skill reference asserting user-only, so the
dual-identity guard added by #2199 fails on main.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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