The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
fix(core): URL-encode bgColor in mermaid API calls (#34461)
Nhan Nguyene99ccbc126d2
diff --git a/libs/core/langchain_core/runnables/graph_mermaid.py b/libs/core/langchain_core/runnables/graph_mermaid.pyindex bda9d33cd3..1a1d7aa667 100644--- a/libs/core/langchain_core/runnables/graph_mermaid.py+++ b/libs/core/langchain_core/runnables/graph_mermaid.py@@ -8,6 +8,7 @@ import randomimport reimport stringimport time+import urllib.parsefrom dataclasses import asdictfrom pathlib import Pathfrom typing import TYPE_CHECKING, Any, Literal@@ -434,9 +435,11 @@ def _render_mermaid_using_api(if background_color is not None and not _HEX_COLOR_PATTERN.match(background_color):background_color = f"!{background_color}"+ # URL-encode the background color to handle special characters like '!'+ encoded_bg_color = urllib.parse.quote(str(background_color), safe="")image_url = (f"{base_url}/img/{mermaid_syntax_encoded}"- f"?type={file_type}&bgColor={background_color}"+ f"?type={file_type}&bgColor={encoded_bg_color}")error_msg_suffix = (