docs(im): recommend user identity for message fetch, add bot-not-in-group fallback guidance#219
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 (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdded documentation guidance for Lark IM message-reading/listing commands advising a preferred Changes
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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Greptile SummaryThis PR adds a "Fetching Messages: Prefer User Identity" section to Confidence Score: 5/5Documentation-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
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]
Reviews (2): Last reviewed commit: "docs(im): recommend user identity for me..." | Re-trigger Greptile |
There was a problem hiding this comment.
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
…roup fallback guidance Change-Id: Ibf1b0afa8f3bfe73cc58715e479ae156dcc7c5f7
c193b00 to
4f40790
Compare
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
Fetching Messages: Prefer User Identitysection toskills/lark-im/SKILL.md--as userfirst; fall back to--as botif user scope is missing; retry with--as userif bot fails due to "not in group"Test Plan
SKILL.mdRelated Issues
N/A
Summary by CodeRabbit