feat: support VC bot event consume#1589
Conversation
📝 WalkthroughWalkthroughAdds bot VC event keys and handlers that normalize meeting payloads into ChangesVC bot event processing
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1589 +/- ##
==========================================
+ Coverage 74.74% 74.77% +0.02%
==========================================
Files 799 800 +1
Lines 80380 80512 +132
==========================================
+ Hits 60084 60203 +119
- Misses 15849 15860 +11
- Partials 4447 4449 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@8581b1cd4c81481038fe9ce3683a7a9e25de6754🧩 Skill updatenpx skills add larksuite/cli#features/F-vc-meeting-contract -y -g |
There was a problem hiding this comment.
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 `@events/vc/bot_events.go`:
- Around line 41-45: Treat payloads with trailing garbage as malformed in the
event parsing flow. In `decodeEvent` (and any shared path used by
`RawEvent`/`json.Marshal(out)`), after `decoder.Decode(&payload)` also verify
there is no extra non-whitespace data remaining in the decoder stream, and fall
back to the raw-passthrough return when any trailing bytes are present. Add a
test covering a valid JSON object followed by junk to ensure the
malformed-passthrough behavior stays covered.
In `@skills/lark-event/references/lark-event-vc.md`:
- Around line 21-27: The vc-event reference table currently mixes OAuth scopes
with Developer Console prerequisites for the bot events, which makes the Scope
column misleading. Update the markdown table in the lark-event-vc reference so
the bot rows for vc.bot.meeting_invited_v1, vc.bot.meeting_event_v1, and
vc.bot.meeting_ended_v1 clearly separate the Developer Console subscription
requirement from the OAuth Scope column, while keeping the user event rows
unchanged.
🪄 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: a39f672a-63f4-4b8b-a0ba-a171ac37be89
📒 Files selected for processing (5)
events/vc/bot_events.goevents/vc/bot_events_test.goevents/vc/register.goskills/lark-event/SKILL.mdskills/lark-event/references/lark-event-vc.md
| decoder := json.NewDecoder(bytes.NewReader(raw.Payload)) | ||
| decoder.UseNumber() | ||
| if err := decoder.Decode(&payload); err != nil { | ||
| return raw.Payload, nil //nolint:nilerr // passthrough on malformed payload so consumers still see the event | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Treat trailing bytes as malformed too.
json.Decoder.Decode only consumes the first JSON value. A payload like {"header":{...}} junk gets past Line 43, but RawEvent still contains invalid JSON, so the json.Marshal(out) at Line 62 fails and the consume loop drops the event instead of doing the intended raw passthrough.
Suggested fix
import (
"bytes"
"context"
"encoding/json"
+ "io"
"sort"
@@
decoder := json.NewDecoder(bytes.NewReader(raw.Payload))
decoder.UseNumber()
if err := decoder.Decode(&payload); err != nil {
return raw.Payload, nil //nolint:nilerr // passthrough on malformed payload so consumers still see the event
}
+ var trailing any
+ if err := decoder.Decode(&trailing); err != io.EOF {
+ return raw.Payload, nil //nolint:nilerr // passthrough when extra trailing bytes make the payload malformed
+ }Please add a test case for “valid JSON + trailing garbage” to keep the malformed-passthrough contract covered.
Also applies to: 54-62
🤖 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 `@events/vc/bot_events.go` around lines 41 - 45, Treat payloads with trailing
garbage as malformed in the event parsing flow. In `decodeEvent` (and any shared
path used by `RawEvent`/`json.Marshal(out)`), after `decoder.Decode(&payload)`
also verify there is no extra non-whitespace data remaining in the decoder
stream, and fall back to the raw-passthrough return when any trailing bytes are
present. Add a test covering a valid JSON object followed by junk to ensure the
malformed-passthrough behavior stays covered.
| | EventKey | Scope | Auth | | ||
| |---|---|---| | ||
| | `vc.meeting.participant_meeting_ended_v1` | `vc:meeting.meetingevent:read` | user | | ||
| | `vc.note.generated_v1` | `vc:note:read` | user | | ||
| | `vc.bot.meeting_invited_v1` | App event subscription in the Developer Console | bot | | ||
| | `vc.bot.meeting_event_v1` | App event subscription in the Developer Console | bot | | ||
| | `vc.bot.meeting_ended_v1` | App event subscription in the Developer Console | bot | |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Separate the bot console prerequisite from the Scope column.
The bot rows are not OAuth scopes; they’re Developer Console subscription requirements. As written, this reads like a scope users should configure, which is misleading.
Suggested fix
-| EventKey | Scope | Auth |
+| EventKey | Scope / Console requirement | Auth |
@@
-| `vc.bot.meeting_invited_v1` | App event subscription in the Developer Console | bot |
-| `vc.bot.meeting_event_v1` | App event subscription in the Developer Console | bot |
-| `vc.bot.meeting_ended_v1` | App event subscription in the Developer Console | bot |
+| `vc.bot.meeting_invited_v1` | Developer Console app event subscription | bot |
+| `vc.bot.meeting_event_v1` | Developer Console app event subscription | bot |
+| `vc.bot.meeting_ended_v1` | Developer Console app event subscription | bot |📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| | EventKey | Scope | Auth | | |
| |---|---|---| | |
| | `vc.meeting.participant_meeting_ended_v1` | `vc:meeting.meetingevent:read` | user | | |
| | `vc.note.generated_v1` | `vc:note:read` | user | | |
| | `vc.bot.meeting_invited_v1` | App event subscription in the Developer Console | bot | | |
| | `vc.bot.meeting_event_v1` | App event subscription in the Developer Console | bot | | |
| | `vc.bot.meeting_ended_v1` | App event subscription in the Developer Console | bot | | |
| | EventKey | Scope / Console requirement | Auth | | |
| |---|---|---| | |
| | `vc.meeting.participant_meeting_ended_v1` | `vc:meeting.meetingevent:read` | user | | |
| | `vc.note.generated_v1` | `vc:note:read` | user | | |
| | `vc.bot.meeting_invited_v1` | Developer Console app event subscription | bot | | |
| | `vc.bot.meeting_event_v1` | Developer Console app event subscription | bot | | |
| | `vc.bot.meeting_ended_v1` | Developer Console app event subscription | bot | |
🤖 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 `@skills/lark-event/references/lark-event-vc.md` around lines 21 - 27, The
vc-event reference table currently mixes OAuth scopes with Developer Console
prerequisites for the bot events, which makes the Scope column misleading.
Update the markdown table in the lark-event-vc reference so the bot rows for
vc.bot.meeting_invited_v1, vc.bot.meeting_event_v1, and vc.bot.meeting_ended_v1
clearly separate the Developer Console subscription requirement from the OAuth
Scope column, while keeping the user event rows unchanged.
Summary
vc.bot.*event processors and bot-only event registrationValidation
python3 tooling/scripts/limited_compile.py --cwd workspace/worktrees/F-vc-meeting-contract/larksuite-cli --label gate4-acceptance-vc-build -- go build ./events/vcGate4 feature:
F-vc-meeting-contractSummary by CodeRabbit
New Features
Bug Fixes
Documentation