Describe the bug
Rendering a physical plan in tree format can panic when an operator name or detail contains multibyte UTF-8 characters. The renderer measures text in characters but uses those character positions as byte offsets when slicing the original string. Character positions are not necessarily valid UTF-8 boundaries.
A representative panic is an invalid string slice boundary inside a multibyte character in datafusion/physical-plan/src/display.rs.
To Reproduce
Render a tree-format physical plan whose node text is long enough to wrap or truncate and contains a multibyte character, such as an emoji. The wrapping path in TreeRenderVisitor::split_string_buffer or the truncation path in TreeRenderVisitor::adjust_text_for_rendering can slice the string at a character index interpreted as a byte index.
Expected behavior
Tree-format plan rendering should wrap and truncate UTF-8 text without panicking, while preserving the existing character-count-based rendering behavior.
Additional context
The fix can iterate over chars consistently when selecting wrapped and truncated text, and should include regression tests for both paths. This issue is intentionally scoped to preventing invalid UTF-8 slicing; display-column widths for wide glyphs and combining characters are a separate concern.
Describe the bug
Rendering a physical plan in tree format can panic when an operator name or detail contains multibyte UTF-8 characters. The renderer measures text in characters but uses those character positions as byte offsets when slicing the original string. Character positions are not necessarily valid UTF-8 boundaries.
A representative panic is an invalid string slice boundary inside a multibyte character in datafusion/physical-plan/src/display.rs.
To Reproduce
Render a tree-format physical plan whose node text is long enough to wrap or truncate and contains a multibyte character, such as an emoji. The wrapping path in TreeRenderVisitor::split_string_buffer or the truncation path in TreeRenderVisitor::adjust_text_for_rendering can slice the string at a character index interpreted as a byte index.
Expected behavior
Tree-format plan rendering should wrap and truncate UTF-8 text without panicking, while preserving the existing character-count-based rendering behavior.
Additional context
The fix can iterate over chars consistently when selecting wrapped and truncated text, and should include regression tests for both paths. This issue is intentionally scoped to preventing invalid UTF-8 slicing; display-column widths for wide glyphs and combining characters are a separate concern.