Skip to content

feat: support event share link and error details#583

Merged
hugang-lark merged 2 commits intomainfrom
event_share
Apr 21, 2026
Merged

feat: support event share link and error details#583
hugang-lark merged 2 commits intomainfrom
event_share

Conversation

@hugang-lark
Copy link
Copy Markdown
Collaborator

@hugang-lark hugang-lark commented Apr 21, 2026

Summary

This PR introduces unified error handling for calendar APIs to improve error readability, and adds support for retrieving event share links.

Changes

  • Added wrapPredefinedError and getErrorDetailValue in the shortcuts/calendar directory for unified error handling.
  • Defined 190014 (Invalid Params) as a standalone constant errCodeInvalidParamsWithDetail for global interception.
  • Automatically extracted API error detail values and appended them to the outer error messages to improve log readability.
  • Updated SKILL.md to include documentation and permission requirements for the new share_info command.
  • Added a guideline in SKILL.md requiring a 2-second delay after calendar write operations (delete/patch) to avoid data synchronization issues.

Test Plan

  • Unit tests pass
  • Manually verified by running lark-cli calendar events share_info --params '{"calendar_id": "primary", "event_id": "xxxx_0"}' to generate the share link.

Related Issues

  • None

Summary by CodeRabbit

  • Bug Fixes

    • Calendar API errors now surface detailed error information in messages and report rollback failures more clearly.
  • New Features

    • Added documentation for event sharing (share link) in calendar operations.
  • Documentation

    • Added guidance to wait 2 seconds after deleting or patching events before performing follow-up validation.
  • Tests

    • Added tests covering detailed API-error handling and rollback scenarios.

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

coderabbitai Bot commented Apr 21, 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: ae2f340c-b393-4288-b0ef-2a2ffc9053ad

📥 Commits

Reviewing files that changed from the base of the PR and between eebed94 and 2c6b118.

📒 Files selected for processing (6)
  • shortcuts/calendar/calendar_agenda.go
  • shortcuts/calendar/calendar_create.go
  • shortcuts/calendar/calendar_freebusy.go
  • shortcuts/calendar/calendar_test.go
  • shortcuts/calendar/errors.go
  • skills/lark-calendar/SKILL.md
✅ Files skipped from review due to trivial changes (1)
  • shortcuts/calendar/calendar_create.go
🚧 Files skipped from review as they are similar to previous changes (4)
  • shortcuts/calendar/errors.go
  • skills/lark-calendar/SKILL.md
  • shortcuts/calendar/calendar_test.go
  • shortcuts/calendar/calendar_agenda.go

📝 Walkthrough

Walkthrough

Centralized 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

Cohort / File(s) Summary
Error Handling Infrastructure
shortcuts/calendar/errors.go
New file adding errCodeInvalidParamsWithDetail, getErrorDetailValue, and wrapPredefinedError(err error) error to extract detail values and wrap predefined API exit errors (code 190014).
Calendar API Callsites
shortcuts/calendar/calendar_agenda.go, shortcuts/calendar/calendar_create.go, shortcuts/calendar/calendar_freebusy.go
Apply wrapPredefinedError(err) immediately after runtime/API calls and before existing error-return logic; also wrap rollback DELETE errors in the create flow.
Tests
shortcuts/calendar/calendar_test.go
Added tests covering error-wrapping behavior for code 190014 with/without error.details[].value, including malformed-detail cases and rollback assertions for CalendarCreate.
Documentation / Skill
skills/lark-calendar/SKILL.md
Added instruction requiring a 2-second wait after delete/patch before validation queries (not to be exposed to users) and documented events.share_info mapping to calendar:calendar.event:read scope.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • zhaoleibd

Poem

🐰 I peeked at errors, pulled out the seed,

Turned tangled messages into what they need.
I hop, I wrap, then quietly wait two,
So calendars align and testers smile too. 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 13.33% 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 and concisely summarizes the two main changes: support for event share links and improved error detail handling.
Description check ✅ Passed The description covers all required template sections with sufficient detail: summary explains the purpose, changes lists the main modifications, test plan describes verification approach, and related issues is addressed.
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.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch event_share

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 and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.98%. Comparing base (fbed6be) to head (2c6b118).
⚠️ Report is 1 commits behind head on main.

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 Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 21, 2026

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add larksuite/cli#event_share -y -g

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: 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 | 🟠 Major

Report both attendee-add and rollback failures.

In the rollback-failure branch, Line 233 formats rollbackErr as the attendee-add failure and drops the original err. 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

📥 Commits

Reviewing files that changed from the base of the PR and between ccc27ce and d0479c8.

📒 Files selected for processing (5)
  • shortcuts/calendar/calendar_agenda.go
  • shortcuts/calendar/calendar_create.go
  • shortcuts/calendar/calendar_freebusy.go
  • shortcuts/calendar/errors.go
  • skills/lark-calendar/SKILL.md

Comment thread shortcuts/calendar/errors.go
Comment thread skills/lark-calendar/SKILL.md
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Change-Id: I4876df38effe44de04e587ac18ace7e230c9fa3a
@hugang-lark hugang-lark merged commit e02c442 into main Apr 21, 2026
21 of 22 checks passed
@hugang-lark hugang-lark deleted the event_share branch April 21, 2026 09:51
@liangshuo-1 liangshuo-1 mentioned this pull request Apr 21, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain/calendar PR touches the calendar domain feature size/M Single-domain feat or fix with limited business impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants