Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
fix(rag): preserve Notion mention and equation text (#42171)
Bruce-Yiib2a5b3beba5f
diff --git a/api/core/rag/extractor/notion_extractor.py b/api/core/rag/extractor/notion_extractor.pyindex f8b849255c1..10f1bd984a6 100644--- a/api/core/rag/extractor/notion_extractor.py+++ b/api/core/rag/extractor/notion_extractor.py@@ -205,9 +205,8 @@ class NotionExtractor(BaseExtractor):else:if "rich_text" in result_obj:for rich_text in result_obj["rich_text"]:- # skip if doesn't have text object- if "text" in rich_text:- text = rich_text["text"]["content"]+ text = rich_text.get("plain_text") or rich_text.get("text", {}).get("content", "")+ if text:cur_result_text_arr.append(text)result_block_id = result["id"]@@ -263,9 +262,8 @@ class NotionExtractor(BaseExtractor):else:if "rich_text" in result_obj:for rich_text in result_obj["rich_text"]:- # skip if doesn't have text object- if "text" in rich_text:- text = rich_text["text"]["content"]+ text = rich_text.get("plain_text") or rich_text.get("text", {}).get("content", "")+ if text:prefix = "\t" * num_tabscur_result_text_arr.append(prefix + text)result_block_id = result["id"]diff --git a/api/tests/unit_tests/core/rag/extractor/test_notion_page_rich_text.py b/api/tests/unit_tests/core/rag/extractor/test_notion_page_rich_text.pynew file mode 100644index 00000000000..4e403e311a7--- /dev/null+++ b/api/tests/unit_tests/core/rag/extractor/test_notion_page_rich_text.py@@ -0,0 +1,65 @@+from unittest import mock++from core.rag.extractor import notion_extractor+++def _mock_response(data: dict[str, object]) -> mock.Mock:+ response = mock.Mock()+ response.status_code = 200+ response.text = ""+ response.json.return_value = data+ return response+++def _extractor() -> notion_extractor.NotionExtractor:+ return notion_extractor.NotionExtractor(+ notion_workspace_id="ws",+ notion_obj_id="obj",+ notion_page_type="page",+ tenant_id="tenant",+ notion_access_token="token",+ )+++def _mixed_rich_text() -> list[dict[str, object]]:+ return [+ {"type": "text", "plain_text": "See ", "text": {"content": "See "}},+ {+ "type": "mention",+ "plain_text": "Project Alpha",+ "mention": {"type": "page", "page": {"id": "page-id"}},+ },+ {"type": "equation", "plain_text": "E = mc^2", "equation": {"expression": "E = mc^2"}},+ ]+++def _paragraph_payload() -> dict[str, object]:+ return {+ "results": [+ {+ "type": "paragraph",+ "id": "paragraph-id",+ "has_children": False,+ "paragraph": {"rich_text": _mixed_rich_text()},+ }+ ],+ "next_cursor": None,+ }+++def test_get_notion_block_data_preserves_mentions_and_equations() -> None:+ extractor = _extractor()++ with mock.patch("httpx.request", return_value=_mock_response(_paragraph_payload())):+ lines = extractor._get_notion_block_data("page-id")++ assert lines == ["See \nProject Alpha\nE = mc^2\n\n"]+++def test_read_block_preserves_mentions_and_equations() -> None:+ extractor = _extractor()++ with mock.patch("httpx.request", return_value=_mock_response(_paragraph_payload())):+ content = extractor._read_block("child-block-id", num_tabs=1)++ assert content == "\tSee \n\tProject Alpha\n\tE = mc^2\n\n"