-
Notifications
You must be signed in to change notification settings - Fork 19k
fix(core): resolve mermaid node id collisions when special chars are used #32857
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub. |
CodSpeed WallTime Performance ReportMerging #32857 will not alter performanceComparing
|
CodSpeed Instrumentation Performance ReportMerging #32857 will not alter performanceComparing Summary
|
libs/core/tests/unit_tests/runnables/__snapshots__/test_graph.ambr
Outdated
Show resolved
Hide resolved
""" | ||
Keep [a-zA-Z0-9_-] characters unchanged. | ||
Map every other character -> \ + lowercase hex codepoint. | ||
Result is only [a-zA-Z0-9\\_-], which is Mermaid compatible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mermaid node ids can contain _
, -
, and \
. Kept _
and -
so slug is more human-readable. Use \
to escape code point representations.
@@ -1913,15 +1934,15 @@ | |||
graph TD; | |||
PromptInput --> PromptTemplate; | |||
PromptTemplate --> FakeListLLM; | |||
Parallel_as_list_as_str_Input --> CommaSeparatedListOutputParser; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fyi this was Parallel<as_list,as_str>Input
and the previous function implementation replaced all nonascii with _
. That's why it looks cleaner. But not the approach we want.
aa19ebd
to
d610150
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!! Thanks for iterating
Description
_escape_node_label
) with_to_safe_id
, which converts a string into a unique, Mermaid-compatible node id. Ensures nodes with special characters always render correctly.Before
开
) replaced with_
. Causes collisions between nodes with names that are the same length and contain all non-safe characters:After
Tests
test_graph_mermaid_escape_node_label()
totest_graph_mermaid_to_safe_id()
and update function logic to use_to_safe_id
test_graph_mermaid_special_chars()
Issue
Fixes langchain-ai/langgraph#6036