feat: add Feishu/Lark WASM channel plugin#1110
Conversation
part of nearai#1046 - Implement Feishu Event Subscription v2.0 webhook (URL verification + im.message.receive_v1) - Token exchange via workspace-cached app credentials with 5-min pre-expiry refresh - Host-side secret injection into config JSON (setup.rs) so WASM can access app_id/app_secret without env vars - Reply and broadcast via /open-apis/im/v1/messages - Enforce allow_from user filtering in message handler - DM pairing flow with owner_id restriction - Dual API base support: open.feishu.cn (Feishu) / open.larksuite.com (Lark) - Registry manifest, bundled channel entry, messaging bundle integration - Strip raw config_json debug log to prevent secret leakage
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a significant new feature by adding a Feishu/Lark WASM channel plugin. This enables the platform to seamlessly integrate with Feishu and Lark bots, allowing for message reception via webhooks and outbound messaging. The changes include secure handling of API credentials, robust token management, and flexible configuration options to support various deployment scenarios and user interaction policies, thereby expanding the system's communication capabilities. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new WASM channel plugin for Feishu/Lark, which is a significant feature addition. The implementation is comprehensive, covering webhook handling for Event Subscription v2.0, tenant access token exchange with caching, and message processing that includes user filtering and a DM pairing flow. The host-side changes to inject secrets directly into the WASM configuration for token exchange are well-designed. The code is well-structured and follows the existing patterns for WASM components in the project. I have one suggestion to improve error handling in the pairing request logic to make it more robust, aligning with best practices for clear error reporting.
| let _ = channel_host::pairing_upsert_request( | ||
| "feishu", | ||
| sender_id, | ||
| &meta.to_string(), | ||
| ); | ||
| channel_host::log( | ||
| channel_host::LogLevel::Info, | ||
| &format!("Pairing request created for {}", sender_id), | ||
| ); |
There was a problem hiding this comment.
The result of channel_host::pairing_upsert_request is currently ignored. If this call fails, the subsequent log message "Pairing request created for..." would be misleading. It's better to handle the Result to ensure the log reflects the actual outcome and to aid in debugging potential issues with the pairing flow. This aligns with the principle of providing clear and semantically correct error messages.
| let _ = channel_host::pairing_upsert_request( | |
| "feishu", | |
| sender_id, | |
| &meta.to_string(), | |
| ); | |
| channel_host::log( | |
| channel_host::LogLevel::Info, | |
| &format!("Pairing request created for {}", sender_id), | |
| ); | |
| match channel_host::pairing_upsert_request("feishu", sender_id, &meta.to_string()) { | |
| Ok(_) => channel_host::log( | |
| channel_host::LogLevel::Info, | |
| &format!("Pairing request created for {}", sender_id), | |
| ), | |
| Err(e) => channel_host::log( | |
| channel_host::LogLevel::Error, | |
| &format!("Failed to create pairing request for {}: {}", sender_id, e), | |
| ), | |
| } |
References
- Create specific error variants for different failure modes (e.g.,
DownloadFailedwith a URL string vs.ManifestReadwith a file path) to provide semantically correct and clear error messages. This comment improves error reporting by logging the actual error, which is a step towards providing semantically correct and clear error messages.
zmanian
left a comment
There was a problem hiding this comment.
Solid WASM channel implementation following established patterns (Telegram, Slack, Discord). Token exchange with 5-min pre-expiry refresh is properly implemented. Host-side integration (setup.rs, registry manifest, bundled channel entry) is complete. This is the better-integrated of the two competing Feishu PRs. LGTM.
|
This PR is approved and CI is green — could you help merge it? Thanks! |
…earai#1200) The Feishu channel merged in nearai#1110 could not be compiled due to mismatches with the WIT-generated bindings. CI did not catch this because standalone WASM channel crates are outside the main workspace. - Replace nonexistent export_sandboxed_channel! with export! macro - Fix http_request body arg: &String -> .as_bytes() for Option<&[u8]> - Fix pairing_is_allowed arg: &String -> Some(&str) for Option<&str> - Fix emit_message arg: pass &EmittedMessage instead of owned value - Add Default derive to TenantAccessTokenData for serde deserialization - Remove unused imports (Attachment, PollConfig) - Track Cargo.lock consistent with other channel crates
part of nearai#1046 - Implement Feishu Event Subscription v2.0 webhook (URL verification + im.message.receive_v1) - Token exchange via workspace-cached app credentials with 5-min pre-expiry refresh - Host-side secret injection into config JSON (setup.rs) so WASM can access app_id/app_secret without env vars - Reply and broadcast via /open-apis/im/v1/messages - Enforce allow_from user filtering in message handler - DM pairing flow with owner_id restriction - Dual API base support: open.feishu.cn (Feishu) / open.larksuite.com (Lark) - Registry manifest, bundled channel entry, messaging bundle integration - Strip raw config_json debug log to prevent secret leakage
part of nearai#1046 - Implement Feishu Event Subscription v2.0 webhook (URL verification + im.message.receive_v1) - Token exchange via workspace-cached app credentials with 5-min pre-expiry refresh - Host-side secret injection into config JSON (setup.rs) so WASM can access app_id/app_secret without env vars - Reply and broadcast via /open-apis/im/v1/messages - Enforce allow_from user filtering in message handler - DM pairing flow with owner_id restriction - Dual API base support: open.feishu.cn (Feishu) / open.larksuite.com (Lark) - Registry manifest, bundled channel entry, messaging bundle integration - Strip raw config_json debug log to prevent secret leakage
Summary
Change Type
Linked Issue
part of #1046
Validation
cargo fmtcargo clippy --all --benches --tests --examples --all-featuresSecurity Impact
None
Database Impact
None
Blast Radius
Rollback Plan
Review track: