Skip to content

fix(feishu): resolve compilation errors in Feishu/Lark WASM channel (#1200)#1204

Merged
zmanian merged 1 commit intonearai:stagingfrom
reidliu41:fix/1200-feishu-compilation
Mar 15, 2026
Merged

fix(feishu): resolve compilation errors in Feishu/Lark WASM channel (#1200)#1204
zmanian merged 1 commit intonearai:stagingfrom
reidliu41:fix/1200-feishu-compilation

Conversation

@reidliu41
Copy link
Copy Markdown
Contributor

Summary

The Feishu channel WASM crate could not be compiled due to mismatches
with the WIT-generated bindings.

  • 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

Change Type

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • CI/Infrastructure
  • Security
  • Dependencies

Linked Issue

Closes #1200

Validation

  • cargo fmt
  • cargo clippy --all --benches --tests --examples --all-features
  • Relevant tests pass:
  • Manual testing:

Security Impact

Database Impact

Blast Radius

Rollback Plan


Review track:

@github-actions github-actions bot added size: L 200-499 changed lines risk: low Changes to docs, tests, or low-risk modules contributor: experienced 6-19 merged PRs labels Mar 15, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 addresses critical compilation errors within the Feishu/Lark WASM channel. The changes primarily involve updating macro usage, correcting function argument types to align with WIT-generated bindings, and refining data structures for proper serialization. These fixes ensure the channel can compile successfully and operate as intended, improving the stability and maintainability of the Feishu integration.

Highlights

  • Compilation Fixes: Resolved compilation errors in the Feishu/Lark WASM channel by addressing mismatches with WIT-generated bindings.
  • Macro Usage: Replaced the nonexistent export_sandboxed_channel! macro with the correct export! macro.
  • Function Argument Types: Corrected argument types for http_request (body from &String to .as_bytes() for Option<&[u8]>), pairing_is_allowed (argument from &String to Some(&str) for Option<&str>), and emit_message (passing &EmittedMessage instead of an owned value).
  • Serialization: Added the Default derive to TenantAccessTokenData to enable proper Serde deserialization.
  • Dependency Management: Removed unused imports (Attachment, PollConfig) and added Cargo.lock to ensure consistent dependency tracking across channel crates.
Changelog
  • channels-src/feishu/Cargo.lock
    • Added Cargo.lock to track consistent dependencies.
  • channels-src/feishu/src/lib.rs
    • Removed unused imports for Attachment and PollConfig.
    • Added Default derive to TenantAccessTokenData struct for Serde deserialization.
    • Replaced export_sandboxed_channel! macro with export!.
    • Refactored json_response call for improved readability.
    • Updated argument type for channel_host::pairing_is_allowed from &String to Option<&str> and refactored logging and variable assignments.
    • Refactored serde_json::to_string call for improved readability.
    • Modified channel_host::emit_message to accept a reference to EmittedMessage instead of an owned value.
    • Refactored URL string formatting.
    • Updated http_request body argument to pass bytes instead of a string reference.
    • Updated http_request body argument in send_message to pass bytes.
    • Updated http_request body argument in obtain_tenant_token to pass bytes.
    • Refactored log message formatting.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

…earai#1200)

  The Feishu channel WASM crate could not be compiled due to mismatches
  with the WIT-generated bindings.

  - 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
[skip-regression-check]
@reidliu41 reidliu41 force-pushed the fix/1200-feishu-compilation branch from 8e55f92 to b92c8a8 Compare March 15, 2026 13:18
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request updates the Cargo.lock file and refactors the feishu-channel Rust code. Key changes include removing unused types (Attachment, PollConfig), updating the channel export macro, and making various formatting improvements. A notable change is the modification of http_request calls to pass JSON request bodies as byte arrays, which is an improvement for performance and robustness, as suggested by a reviewer, who recommended using serde_json::to_vec for direct serialization to a byte vector to reduce allocations and handle serialization errors gracefully.

Comment on lines +754 to 761
let body_bytes = body.to_string();
let result = channel_host::http_request(
"POST",
&url,
&headers.to_string(),
Some(&body.to_string()),
Some(body_bytes.as_bytes()),
Some(10_000),
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

For consistency and slightly better performance, you can serialize the JSON body directly to a byte vector using serde_json::to_vec. It's recommended to handle potential serialization errors gracefully with map_err for robustness, similar to other serialization calls.

Suggested change
let body_bytes = body.to_string();
let result = channel_host::http_request(
"POST",
&url,
&headers.to_string(),
Some(&body.to_string()),
Some(body_bytes.as_bytes()),
Some(10_000),
);
let body_bytes = serde_json::to_vec(&body).map_err(|e| format!("Failed to serialize body: {}", e))?;
let result = channel_host::http_request(
"POST",
&url,
&headers.to_string(),
Some(&body_bytes),
Some(10_000),
);
References
  1. To improve performance in WASM, avoid unnecessary heap allocations. Serializing directly to a byte vector (Vec<u8>) instead of an intermediate String reduces allocations and avoids redundant UTF-8 validation, which is beneficial for WASM.

Copy link
Copy Markdown
Collaborator

@zmanian zmanian left a comment

Choose a reason for hiding this comment

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

Review: APPROVE

Clean, tightly-scoped compilation fix. All 7 compiler errors from #1200 resolved with correct mechanical fixes:

  • Fixed macro: export_sandboxed_channel! -> export!
  • Fixed http_request body type: Some(&body_json) -> Some(body_json.as_bytes()) for Option<&[u8]> (3 call sites)
  • Fixed pairing_is_allowed arg: &sender_name -> Some(&sender_name) for Option<&str>
  • Fixed emit_message: pass by reference
  • Added Default derive to TenantAccessTokenData (required by serde)
  • Removed unused imports (Attachment, PollConfig)
  • Added Cargo.lock (matches convention for other channel crates)

No .unwrap() in production code. CI all green.

Minor nit (non-blocking): body_bytes variable at line ~754 holds a String, not bytes -- body_str would be a more accurate name.

Safe to merge.

@zmanian zmanian merged commit 3f874e7 into nearai:staging Mar 15, 2026
14 checks passed
@claude
Copy link
Copy Markdown

claude bot commented Mar 15, 2026

Code review

No issues found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor: experienced 6-19 merged PRs risk: low Changes to docs, tests, or low-risk modules size: L 200-499 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feishu/Lark channel CAN NOT BE COMPILED

2 participants