Skip to content

feat(approval): support approval event consumption#1924

Merged
LightsDancer merged 1 commit into
mainfrom
feat/approval-event-consume
Jul 17, 2026
Merged

feat(approval): support approval event consumption#1924
LightsDancer merged 1 commit into
mainfrom
feat/approval-event-consume

Conversation

@LightsDancer

@LightsDancer LightsDancer commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add support for consuming Approval instance and task status change events through lark-cli event consume, including user-auth pre-consume subscription setup, flattened output schemas, and agent-facing documentation.

Changes

  • Register approval.instance.status_changed_v4 and approval.task.status_changed_v4 EventKeys with custom flattened schemas, required user auth scopes, and console event metadata.
  • Add Approval pre-consume subscription setup that calls the instance/task subscription APIs and supports omitted, single, comma-separated, or JSON-array subscription_type values.
  • Document Approval event consumption semantics, output fields, subscription behavior, and usage examples in the lark-event skill references.
  • Add tests for EventKey registration, schema output, subscription parameter parsing, validation errors, flattened payload processing, and event list/schema visibility.

Test Plan

  • Relevant unit tests pass: go test ./cmd/event ./events/approval
  • Manual local verification confirms the lark-cli event schema / lark-cli event list flow works as expected via go run . event schema approval.instance.status_changed_v4 --json, go run . event schema approval.task.status_changed_v4 --json, and go run . event list --json.

Related Issues

  • None

Summary by CodeRabbit

  • New Features

    • Added support for consuming Approval instance and task status-change events (approval.instance.status_changed_v4, approval.task.status_changed_v4).
    • Added subscription_type filtering for Approval subscriptions (empty/omitted, comma-separated, or JSON array).
    • Improved event output shaping, including timestamp formatting and resilient handling of malformed payloads and missing header type.
  • Documentation

    • Added an Approval event consumption guide and expanded the event reference index.
    • Updated related Approval command reference pages with time-range filtering and revised parameters/examples.
  • Tests

    • Expanded schema, registration, and output validation for the new Approval EventKeys and edge cases.

@github-actions github-actions Bot added the size/L Large or sensitive change across domains or core paths label Jul 16, 2026
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7e011e51-68a1-460e-83bf-07a2da912cf3

📥 Commits

Reviewing files that changed from the base of the PR and between 624fba7 and e876bef.

📒 Files selected for processing (13)
  • cmd/event/list_test.go
  • cmd/event/schema_test.go
  • events/approval/preconsume.go
  • events/approval/register.go
  • events/approval/register_test.go
  • events/approval/types.go
  • events/register.go
  • skills/lark-approval/references/lark-approval-initiate.md
  • skills/lark-approval/references/lark-approval-instances-initiated.md
  • skills/lark-approval/references/lark-approval-tasks-query.md
  • skills/lark-approval/references/lark-approval-tasks-rollback.md
  • skills/lark-event/SKILL.md
  • skills/lark-event/references/lark-event-approval.md
🚧 Files skipped from review as they are similar to previous changes (12)
  • events/register.go
  • cmd/event/list_test.go
  • cmd/event/schema_test.go
  • events/approval/register.go
  • skills/lark-event/references/lark-event-approval.md
  • skills/lark-approval/references/lark-approval-tasks-query.md
  • skills/lark-approval/references/lark-approval-tasks-rollback.md
  • events/approval/types.go
  • skills/lark-approval/references/lark-approval-initiate.md
  • events/approval/register_test.go
  • events/approval/preconsume.go
  • skills/lark-approval/references/lark-approval-instances-initiated.md

📝 Walkthrough

Walkthrough

Approval instance and task status-change events are added with typed flattened outputs, user-specific pre-consume subscriptions, global registration, validation tests, event discovery coverage, and CLI documentation updates.

Changes

Approval event consumption

Layer / File(s) Summary
Event contracts and registration
events/approval/types.go, events/approval/register.go, events/register.go
Defines flattened approval event outputs, subscription parameters, key metadata, scopes, and global event registration.
Pre-consume subscription registration
events/approval/preconsume.go
Parses subscription types, registers selected approval relations through the API, and reports validation or partial-registration errors without unsubscribe cleanup.
Status-change payload processing
events/approval/register.go
Maps instance and task event envelopes to typed JSON outputs, with nil handling, malformed-payload passthrough, and event-type fallback.
Schema, listing, and integration validation
events/approval/register_test.go, cmd/event/schema_test.go, cmd/event/list_test.go
Tests approval metadata, schemas, subscriptions, errors, payload mapping, registration, and event list/schema discovery.
Approval CLI and event documentation
skills/lark-approval/references/*, skills/lark-event/SKILL.md, skills/lark-event/references/lark-event-approval.md
Documents approval command parameters, filtering, rollback behavior, event subscriptions, scopes, output fields, and consumption examples.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant event.consume
  participant approvalSubscriptionPreConsume
  participant event.APIClient
  participant ApprovalSubscriptionAPI
  event.consume->>approvalSubscriptionPreConsume: provide subscription_type
  approvalSubscriptionPreConsume->>event.APIClient: POST relation registration
  event.APIClient->>ApprovalSubscriptionAPI: create approval subscription
  ApprovalSubscriptionAPI-->>event.APIClient: return registration result
  event.APIClient-->>approvalSubscriptionPreConsume: keep registration without unsubscribe
Loading

Possibly related PRs

  • larksuite/cli#1923: Adds related Approval event registration, processing, schema, and discovery test coverage.

Suggested labels: feature

Suggested reviewers: liangshuo-1

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding approval event consumption support.
Description check ✅ Passed The description follows the template and covers summary, changes, test plan, and related issues.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.
✨ 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 feat/approval-event-consume

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@cmd/event/list_test.go`:
- Around line 41-42: Isolate configuration state in both cmd/event/list_test.go
sites: in TestRunList_TextOutput (lines 41-42) and TestRunList_JSONOutput (lines
97-98), set LARKSUITE_CLI_CONFIG_DIR to t.TempDir() immediately before each
cmdutil.TestFactory call so local configuration cannot affect either test’s
output.
🪄 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: 81cf8151-1eed-4c90-bd83-3f53e4b9e883

📥 Commits

Reviewing files that changed from the base of the PR and between 7081960 and 321ffb6.

📒 Files selected for processing (13)
  • cmd/event/list_test.go
  • cmd/event/schema_test.go
  • events/approval/preconsume.go
  • events/approval/register.go
  • events/approval/register_test.go
  • events/approval/types.go
  • events/register.go
  • skills/lark-approval/references/lark-approval-initiate.md
  • skills/lark-approval/references/lark-approval-instances-initiated.md
  • skills/lark-approval/references/lark-approval-tasks-query.md
  • skills/lark-approval/references/lark-approval-tasks-rollback.md
  • skills/lark-event/SKILL.md
  • skills/lark-event/references/lark-event-approval.md

Comment thread cmd/event/list_test.go
@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

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

🧩 Skill update

npx skills add larksuite/cli#feat/approval-event-consume -y -g

@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1924      +/-   ##
==========================================
+ Coverage   74.96%   75.02%   +0.05%     
==========================================
  Files         892      894       +2     
  Lines       94077    94294     +217     
==========================================
+ Hits        70529    70746     +217     
  Misses      18137    18137              
  Partials     5411     5411              

☔ View full report in Codecov by Harness.
📢 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.

@LightsDancer
LightsDancer force-pushed the feat/approval-event-consume branch 2 times, most recently from 64ac8c7 to 624fba7 Compare July 17, 2026 09:42
Register approval.instance.status_changed_v4 and approval.task.status_changed_v4 with custom flattened schemas and user-auth pre-consume subscription setup.

Handle approval subscription_type as optional multi-value pre-registration metadata: omitted values register both involved and managed relations, explicit values can be single, comma-separated, or JSON array, and consumers do not unsubscribe on exit.

Report partial approval subscription registration failures with registered and failed relation context while preserving the underlying typed error classification.

Document approval event output fields and subscription semantics, and refresh approval skill references from API metadata.
@LightsDancer
LightsDancer force-pushed the feat/approval-event-consume branch from 624fba7 to e876bef Compare July 17, 2026 09:58
@LightsDancer
LightsDancer merged commit 1efe2df into main Jul 17, 2026
40 of 42 checks passed
@LightsDancer
LightsDancer deleted the feat/approval-event-consume branch July 17, 2026 10:38
@liangshuo-1 liangshuo-1 mentioned this pull request Jul 17, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L Large or sensitive change across domains or core paths

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants