feat: support event share link and error details#583
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 (6)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughCentralized error-wrapping for Lark Calendar shortcuts was added: a new helper extracts detail values from specific API error payloads (code 190014) and augments API errors. The wrapper is applied to calendar agenda, create, and freebusy API calls; tests and SKILL docs were updated accordingly. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 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✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #583 +/- ##
==========================================
+ Coverage 60.92% 60.98% +0.05%
==========================================
Files 399 400 +1
Lines 34089 34119 +30
==========================================
+ Hits 20770 20806 +36
+ Misses 11395 11389 -6
Partials 1924 1924 ☔ 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@2c6b11830d05c0aed23f82cabb81774de7134435🧩 Skill updatenpx skills add larksuite/cli#event_share -y -g |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
shortcuts/calendar/calendar_create.go (1)
225-235:⚠️ Potential issue | 🟠 MajorReport both attendee-add and rollback failures.
In the rollback-failure branch, Line 233 formats
rollbackErras the attendee-add failure and drops the originalerr. When an orphan event may need manual cleanup, the user needs both errors.🐛 Proposed fix
rollbackErr = wrapPredefinedError(rollbackErr) if rollbackErr != nil { - return output.Errorf(output.ExitAPI, "api_error", "failed to add attendees: %v; rollback also failed, orphan event_id=%s needs manual cleanup", rollbackErr, eventId) + return output.Errorf(output.ExitAPI, "api_error", "failed to add attendees: %v; rollback also failed: %v; orphan event_id=%s needs manual cleanup", err, rollbackErr, eventId) }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@shortcuts/calendar/calendar_create.go` around lines 225 - 235, The rollback branch currently logs only rollbackErr and discards the original attendee-add error; update the error handling in the block where wrapPredefinedError(err) is checked (using variables err and rollbackErr and the call to runtime.RawAPI) so the output.Errorf call includes both the original attendee-add error and the rollback failure (e.g., "failed to add attendees: <err>; rollback also failed: <rollbackErr>, orphan event_id=<eventId> needs manual cleanup"), preserving context about calendarId/eventId and using the same output.Errorf path as before to return a combined message.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@shortcuts/calendar/errors.go`:
- Around line 21-66: Add unit tests exercising getErrorDetailValue and
wrapPredefinedError: 1) assert that a non-*output.ExitError or an ExitError with
a different code returns the original error unchanged; 2) construct an
*output.ExitError whose Detail.Code equals errCodeInvalidParamsWithDetail and
whose Detail.Detail contains a map with "details":[{"value":"X"}] and assert
wrapPredefinedError returns an output.ErrAPI with message equal to
Detail.Message + ": X" (use output.ExitError and output.ErrAPI helpers from the
diff); 3) add tests where Detail is nil, Detail.Detail is malformed (not a map),
or "details" is missing/empty and assert wrapPredefinedError falls back to
returning the original error; reference getErrorDetailValue,
wrapPredefinedError, errCodeInvalidParamsWithDetail, output.ExitError, and
output.ErrAPI when locating code to test.
In `@skills/lark-calendar/SKILL.md`:
- Line 116: Remove the `share_info` method entry from SKILL.md (the line "-
`share_info` — 获取日程分享链接") since it does not exist; update the documentation to
reference the actual Lark Calendar mechanisms instead (mention `visibility` and
`attendee_ability` and attendee/ACL management as the correct ways to handle
event sharing) and ensure no other sections reference `share_info`.
---
Outside diff comments:
In `@shortcuts/calendar/calendar_create.go`:
- Around line 225-235: The rollback branch currently logs only rollbackErr and
discards the original attendee-add error; update the error handling in the block
where wrapPredefinedError(err) is checked (using variables err and rollbackErr
and the call to runtime.RawAPI) so the output.Errorf call includes both the
original attendee-add error and the rollback failure (e.g., "failed to add
attendees: <err>; rollback also failed: <rollbackErr>, orphan event_id=<eventId>
needs manual cleanup"), preserving context about calendarId/eventId and using
the same output.Errorf path as before to return a combined message.
🪄 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: 3899482a-bfcd-453e-ba83-d1e076b97a06
📒 Files selected for processing (5)
shortcuts/calendar/calendar_agenda.goshortcuts/calendar/calendar_create.goshortcuts/calendar/calendar_freebusy.goshortcuts/calendar/errors.goskills/lark-calendar/SKILL.md
d0479c8 to
eebed94
Compare
Change-Id: I4876df38effe44de04e587ac18ace7e230c9fa3a
eebed94 to
2c6b118
Compare
* feat: support event share info Change-Id: I4876df38effe44de04e587ac18ace7e230c9fa3a * fix: return detail err info for calendar
Summary
This PR introduces unified error handling for calendar APIs to improve error readability, and adds support for retrieving event share links.
Changes
wrapPredefinedErrorandgetErrorDetailValuein theshortcuts/calendardirectory for unified error handling.190014(Invalid Params) as a standalone constanterrCodeInvalidParamsWithDetailfor global interception.SKILL.mdto include documentation and permission requirements for the newshare_infocommand.SKILL.mdrequiring a 2-second delay after calendar write operations (delete/patch) to avoid data synchronization issues.Test Plan
lark-cli calendar events share_info --params '{"calendar_id": "primary", "event_id": "xxxx_0"}'to generate the share link.Related Issues
Summary by CodeRabbit
Bug Fixes
New Features
Documentation
Tests