PydanticSerializationError in lark_document plugin with Feishu trigger #885

Closed
opened 2026-02-16 10:20:50 -05:00 by yindo · 1 comment
Owner

Originally created by @Zane9412 on GitHub (Dec 18, 2025).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues Dify issues & Dify Official Plugins, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.10.1

Plugin version

0.0.2

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

  1. Set up the lark_document plugin in Dify
  2. Configure a Feishu trigger to invoke the plugin.
  3. Trigger the plugin via Feishu.
  4. Observe that the plugin fails with a serialization error.

✔️ Error log

An error occurred in the currently running plugin, please contact the author of currently running plugin for help,
error type: PydanticSerializationError,
error details: Unable to serialize unknown type: <class 'lark_oapi.api.drive.v1.model.bitable_table_record_action_field.BitableTableRecordActionField'>

Originally created by @Zane9412 on GitHub (Dec 18, 2025). ### Self Checks - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [Dify issues](https://github.com/langgenius/dify/issues) & [Dify Official Plugins](https://github.com/langgenius/dify-official-plugins/issues), including closed ones. - [x] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.10.1 ### Plugin version 0.0.2 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce 1. Set up the lark_document plugin in Dify 2. Configure a Feishu trigger to invoke the plugin. 3. Trigger the plugin via Feishu. 4. Observe that the plugin fails with a serialization error. ### ✔️ Error log An error occurred in the currently running plugin, please contact the author of currently running plugin for help, error type: PydanticSerializationError, error details: Unable to serialize unknown type: <class 'lark_oapi.api.drive.v1.model.bitable_table_record_action_field.BitableTableRecordActionField'>
yindo added the bug label 2026-02-16 10:20:50 -05:00
yindo closed this issue 2026-02-16 10:20:50 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Dec 18, 2025):

Hi @xiezhenzhong1225! I'm Dosu and I’m helping the dify-official-plugins team.

The error happens because a Lark API model object (like BitableTableRecordActionField) is being passed to Pydantic without first converting it to a dictionary of primitive types. The event handler code for Feishu triggers in the lark_document plugin is supposed to extract fields from these objects and build plain dicts for serialization. If any branch of the code accidentally passes the raw object (instead of a dict), you'll get this error.

To fix it, review the event handler code for all Feishu triggers—especially where action_list or similar fields are processed. Make sure every action is converted to a dict of primitives before being added to the variables. Here’s a simplified example pattern you should follow:

actions = []
for action in event_data.action_list:
    if action:
        action_info = {
            "action": getattr(action, "action", ""),
            "record_id": getattr(action, "record_id", ""),
            "before_value": str(getattr(action, "before_value", "")),
            "after_value": str(getattr(action, "after_value", "")),
        }
        actions.append(action_info)
variables_dict["actions"] = actions

This approach is already used in the plugin for both record and field change events, but if you have customizations or new event types, ensure you apply the same pattern everywhere you handle Lark API model objects. If you need to serialize other complex objects, consider adding helper functions similar to serialize_user_identity or serialize_user_list for consistency and safety.
Reference: event handler code example

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Dec 18, 2025): <!-- Greeting --> Hi @xiezhenzhong1225! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the dify-official-plugins team. <!-- Answer --> The error happens because a Lark API model object (like BitableTableRecordActionField) is being passed to Pydantic without first converting it to a dictionary of primitive types. The event handler code for Feishu triggers in the lark_document plugin is supposed to extract fields from these objects and build plain dicts for serialization. If any branch of the code accidentally passes the raw object (instead of a dict), you'll get this error. To fix it, review the event handler code for all Feishu triggers—especially where action_list or similar fields are processed. Make sure every action is converted to a dict of primitives before being added to the variables. Here’s a simplified example pattern you should follow: ```python actions = [] for action in event_data.action_list: if action: action_info = { "action": getattr(action, "action", ""), "record_id": getattr(action, "record_id", ""), "before_value": str(getattr(action, "before_value", "")), "after_value": str(getattr(action, "after_value", "")), } actions.append(action_info) variables_dict["actions"] = actions ``` This approach is already used in the plugin for both record and field change events, but if you have customizations or new event types, ensure you apply the same pattern everywhere you handle Lark API model objects. If you need to serialize other complex objects, consider adding helper functions similar to `serialize_user_identity` or `serialize_user_list` for consistency and safety. [Reference: event handler code example](https://github.com/langgenius/dify-official-plugins/blob/6ec14c4625f9095fe84ea7a616f5a119fc04627a/triggers/lark_trigger/events/drive/file_bitable_field_changed_v1.py#L8-L67) <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/28acc3ce-9c35-474b-a6ee-1a9441025c6a?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/28acc3ce-9c35-474b-a6ee-1a9441025c6a?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/28acc3ce-9c35-474b-a6ee-1a9441025c6a?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/28acc3ce-9c35-474b-a6ee-1a9441025c6a?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/28acc3ce-9c35-474b-a6ee-1a9441025c6a?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/28acc3ce-9c35-474b-a6ee-1a9441025c6a?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/28acc3ce-9c35-474b-a6ee-1a9441025c6a?feedback_type=other)</sup> [![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=The%20error%20happens%20because%20a%20Lark%20API%20model%20object%20%28like%20BitableTableRecordActionField%29%20is%20being%20passed%20to%20Pydantic%20without%20first%20converting%20it%20to%20a%20dictionary%20of%20primitive%20types.%20The%20event%20handler%20code%20for%20Feishu%20triggers%20in%20the%20lark_document%20plugin%20is%20supposed%20to%20extract%20fields%20from%20these%20objects%20and%20build%20plain%20dicts%20for%20serialization.%20If%20any%20branch%20of%20the%20code%20accidentally%20passes%20the%20raw%20object%20%28instead%20of%20a%20dict%29%2C%20you%27ll%20get%20this%20error.%0A%0ATo%20fix%20it%2C%20review%20the%20event%20handler%20code%20for%20all%20Feishu%20triggers%E2%80%94especially%20where%20action_list%20or%20similar%20fields%20are%20processed.%20Make%20sure%20every%20action%20is%20converted%20to%20a%20dict%20of%20primitives%20before%20being%20added%20to%20the%20variables.%20Here%E2%80%99s%20a%20simplified%20example%20pattern%20you%20should%20follow%3A%0A%0A%60%60%60python%0Aactions%20%3D%20%5B%5D%0Afor%20action%20in%20event_data.action_list%3A%0A%20%20%20%20if%20action%3A%0A%20%20%20%20%20%20%20%20action_info%20%3D%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22action%22%3A%20getattr%28action%2C%20%22action%22%2C%20%22%22%29%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22record_id%22%3A%20getattr%28action%2C%20%22record_id%22%2C%20%22%22%29%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22before_value%22%3A%20str%28getattr%28action%2C%20%22before_value%22%2C%20%22%22%29%29%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22after_value%22%3A%20str%28getattr%28action%2C%20%22after_value%22%2C%20%22%22%29%29%2C%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20actions.append%28action_info%29%0Avariables_dict%5B%22actions%22%5D%20%3D%20actions%0A%60%60%60%0A%0AThis%20approach%20is%20already%20used%20in%20the%20plugin%20for%20both%20record%20and%20field%20change%20events%2C%20but%20if%20you%20have%20customizations%20or%20new%20event%20types%2C%20ensure%20you%20apply%20the%20same%20pattern%20everywhere%20you%20handle%20Lark%20API%20model%20objects.%20If%20you%20need%20to%20serialize%20other%20complex%20objects%2C%20consider%20adding%20helper%20functions%20similar%20to%20%60serialize_user_identity%60%20or%20%60serialize_user_list%60%20for%20consistency%20and%20safety.%20%20%0A%5BReference%3A%20event%20handler%20code%20example%5D%28https%3A//github.com/langgenius/dify-official-plugins/blob/6ec14c4625f9095fe84ea7a616f5a119fc04627a/triggers/lark_trigger/events/drive/file_bitable_field_changed_v1.py%23L8-L67%29)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify-official-plugins/issues/2290)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#885