fix(feishu): tolerate null multi_url and list fields in card extract

This commit is contained in:
santhreal
2026-07-26 23:19:35 +08:00
committed by Xubin Ren
parent 1e505ff405
commit aaf2eef568
2 changed files with 38 additions and 7 deletions
@@ -1,6 +1,7 @@
import json
from nanobot.channels.feishu.runtime import (
_extract_element_content,
_extract_post_content,
_extract_share_card_content,
)
@@ -60,3 +61,28 @@ def test_extract_post_content_tolerates_null_fields() -> None:
assert "@user" in text
assert "ok" in text
assert images == []
def test_extract_button_tolerates_null_multi_url() -> None:
element = {"tag": "button", "text": {"content": "Go"}, "multi_url": None}
assert _extract_element_content(element) == ["Go"]
def test_extract_column_set_tolerates_null_columns_and_elements() -> None:
assert _extract_element_content({"tag": "column_set", "columns": None}) == []
assert _extract_element_content(
{"tag": "column_set", "columns": [{"elements": None}]}
) == []
def test_extract_div_tolerates_null_fields() -> None:
assert _extract_element_content(
{"tag": "div", "text": {"content": "hi"}, "fields": None}
) == ["hi"]
def test_interactive_card_button_null_multi_url() -> None:
content = {
"elements": [{"tag": "button", "text": {"content": "Go"}, "multi_url": None}]
}
assert _extract_share_card_content(content, "interactive") == "Go"