Skip to content

docs(im): recommend user identity for message fetch, add bot-not-in-group fallback guidance#219

Open
sammi-bytedance wants to merge 1 commit intolarksuite:mainfrom
sammi-bytedance:fix/im-skill-message-fetch-identity
Open

docs(im): recommend user identity for message fetch, add bot-not-in-group fallback guidance#219
sammi-bytedance wants to merge 1 commit intolarksuite:mainfrom
sammi-bytedance:fix/im-skill-message-fetch-identity

Conversation

@sammi-bytedance
Copy link
Copy Markdown
Contributor

@sammi-bytedance sammi-bytedance commented Apr 2, 2026

Summary

When the bot is not a member of a target chat, message-fetch commands fail with a "not in group" error. This PR documents the recommended identity strategy so agents always pick the right identity without manual intervention.

Changes

  • Add Fetching Messages: Prefer User Identity section to skills/lark-im/SKILL.md
  • Document the recommended strategy: prefer --as user first; fall back to --as bot if user scope is missing; retry with --as user if bot fails due to "not in group"

Test Plan

  • Manual verification: skill guidance is visible in SKILL.md
  • Documentation-only change, no runtime behavior affected

Related Issues

N/A

Summary by CodeRabbit

  • Documentation
    • Added guidance for message-reading and listing commands: prefer acting as the user when possible; some search operations are user-only. Describes a clear fallback flow for permission errors — try user first, switch to bot when user scope is missing, and retry user only when bot membership is the blocker. Provides actionable errors for missing read scope or when the bot must be added to a chat.

@github-actions github-actions bot added domain/im PR touches the im domain size/M Single-domain feat or fix with limited business impact labels Apr 2, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 2, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fa2c1f93-fb18-4e38-9030-a72dbc24ddcd

📥 Commits

Reviewing files that changed from the base of the PR and between c4e9482 and 4f40790.

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

📝 Walkthrough

Walkthrough

Added documentation guidance for Lark IM message-reading/listing commands advising a preferred --as user approach with a defined fallback flow between --as user and --as bot when encountering scope or membership errors.

Changes

Cohort / File(s) Summary
Documentation & Guidance
skills/lark-im/SKILL.md
Added guidance describing identity selection for message read/list operations (+chat-messages-list, +threads-messages-list, +messages-mget, +messages-search), recommended --as user preference, and explicit fallback/retry rules for user vs bot authentication and membership/scope errors.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant UserAuth as User Token
    participant BotAuth as Bot Token
    participant LarkAPI as Lark Chat API

    Client->>UserAuth: attempt request (--as user) if user scope available
    alt User token succeeds
        UserAuth->>LarkAPI: call list/read messages
        LarkAPI-->>Client: messages / success
    else User token missing scope or denied
        Client->>BotAuth: attempt request (--as bot)
        alt Bot call succeeds
            BotAuth->>LarkAPI: call list/read messages
            LarkAPI-->>Client: messages / success
        else Bot fails due to "bot not in group"
            alt user scope available
                Client->>UserAuth: retry request (--as user)
                UserAuth->>LarkAPI: call list/read messages
                LarkAPI-->>Client: messages / success
            else
                LarkAPI-->>Client: actionable error (missing im:message:readonly or add bot to chat)
            end
        end
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • YangJunzhou-01

Poem

🐰 I hopped through docs with a careful cheer,
Prefer the user's key when messages aren't near.
If bot's blocked at the gate, try bot then retry,
Or tell them to grant scope — and give a wink goodbye. 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding documentation that recommends user identity for message fetching and includes bot-not-in-group fallback guidance.
Description check ✅ Passed The description is well-structured with all required template sections: Summary explains the motivation, Changes lists the specific additions, Test Plan documents manual verification, and Related Issues is addressed.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Apr 2, 2026

Greptile Summary

This PR adds a "Fetching Messages: Prefer User Identity" section to skills/lark-im/SKILL.md, documenting the recommended identity strategy and a structured fallback decision tree for message-fetch commands. Both previously flagged concerns — the erroneous inclusion of +messages-search in the bot fallback guidance and the circular retry loop — have been addressed in this revision.

Confidence Score: 5/5

Documentation-only change; all previously flagged P1 concerns are resolved; safe to merge.

Both prior blocking issues — +messages-search incorrectly included in bot-fallback guidance, and the circular retry loop — have been explicitly addressed. The new strategy is guarded by explicit conditions that prevent infinite loops. No new logic or runtime code is introduced, so there is no regression risk.

No files require special attention.

Important Files Changed

Filename Overview
skills/lark-im/SKILL.md Adds a clear identity-preference section with a well-guarded 3-step fallback strategy; previous issues (messages-search bot fallback, circular retry) are both resolved in this version.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Fetch messages] --> B[Try --as user]
    B -->|Success| Z[Return results]
    B -->|Fails: missing scope| C[Try --as bot]
    C -->|Success| Z
    C -->|Fails: bot not in group| D{User scope confirmed available?}
    D -->|Yes| E[Retry --as user]
    E --> Z
    D -->|No| F[Surface error: Grant im:message:readonly or add bot to chat]
Loading

Reviews (2): Last reviewed commit: "docs(im): recommend user identity for me..." | Re-trigger Greptile

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
skills/lark-im/SKILL.md (1)

55-57: Fallback sequence is ambiguous after a user-scope failure.

The current steps can conflict logically: after Line 55 says user failed (e.g., missing scope), Line 57 says switch back to user if bot fails “not in group”. Consider rewriting as reason-based branching (e.g., retry user only when user auth/scope is available, otherwise stop with actionable error).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@skills/lark-im/SKILL.md` around lines 55 - 57, The fallback sequence
described by the steps "2. If `--as user` fails" and "3. If `--as bot` fails" is
ambiguous and can conflict; change the prose to a clear reason-based branching
policy: explicitly state that on `--as user` failure you should inspect the
error (e.g., missing user scope) and only fall back to `--as bot` when the
failure is due to user auth/permission issues, while on `--as bot` failure you
should inspect for "bot not in group"/permission errors and only retry `--as
user` when the user credentials/scopes are known to be valid—otherwise surface
an actionable error; update the two numbered steps to include the error checks,
the exact retry conditions, and example actionable messages for each branch.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@skills/lark-im/SKILL.md`:
- Line 51: The list of commands that "prefer --as user" incorrectly includes
+messages-search; update SKILL.md to remove +messages-search from that
dual-identity list (or explicitly mark it as user-only) so operators aren't told
to try --as bot; specifically edit the sentence listing `+chat-messages-list`,
`+threads-messages-list`, `+messages-mget`, `+messages-search` to either drop
`+messages-search` or change it to “+messages-search (user-only)” and ensure the
surrounding guidance references user-only behavior for `+messages-search`
instead of implying bot identity is supported.

---

Nitpick comments:
In `@skills/lark-im/SKILL.md`:
- Around line 55-57: The fallback sequence described by the steps "2. If `--as
user` fails" and "3. If `--as bot` fails" is ambiguous and can conflict; change
the prose to a clear reason-based branching policy: explicitly state that on
`--as user` failure you should inspect the error (e.g., missing user scope) and
only fall back to `--as bot` when the failure is due to user auth/permission
issues, while on `--as bot` failure you should inspect for "bot not in
group"/permission errors and only retry `--as user` when the user
credentials/scopes are known to be valid—otherwise surface an actionable error;
update the two numbered steps to include the error checks, the exact retry
conditions, and example actionable messages for each branch.
🪄 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: a3fd8606-6bbf-46b0-99de-2dc79246b863

📥 Commits

Reviewing files that changed from the base of the PR and between 112dd5f and c4e9482.

📒 Files selected for processing (1)
  • skills/lark-im/SKILL.md

…roup fallback guidance

Change-Id: Ibf1b0afa8f3bfe73cc58715e479ae156dcc7c5f7
@sammi-bytedance sammi-bytedance force-pushed the fix/im-skill-message-fetch-identity branch from c193b00 to 4f40790 Compare April 2, 2026 10:06
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/M Single-domain feat or fix with limited business impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant