Skip to content

fix(callflow): bump Mermaid maxTextSize to prevent diagram rendering failure on large architectures - #5448

Open
Gaurav-meena95 wants to merge 1 commit into
Graphify-Labs:v8from
Gaurav-meena95:fix/callflow-mermaid-max-text-size
Open

Gaurav-meena95 wants to merge 1 commit into
Graphify-Labs:v8from
Gaurav-meena95:fix/callflow-mermaid-max-text-size

Conversation

@Gaurav-meena95

@Gaurav-meena95 Gaurav-meena95 commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #5447

What does this PR do?

Configures maxTextSize: 250000 in graphify/callflow_html.py (both in the mermaid_init directive and client-side mermaidConfig) to prevent Mermaid v11 from throwing Error: Maximum text size in diagram exceeded when rendering architecture diagrams for medium-to-large codebases.

Problem

Mermaid v11 has a default browser text diagram limit of 50,000 characters. When exporting architecture callflows (graphify export callflow-html) for codebases or sections containing 40+ nodes, relations, and source file metadata, the generated flowchart definition easily exceeds 50,000 characters. Because maxTextSize was omitted from the configuration, the browser threw an unhandled promise rejection and aborted diagram rendering.

Solution

  • Added DEFAULT_MAX_TEXT_SIZE = 250_000 (5x default headroom).
  • Configured "maxTextSize": max_text_size in the %%{init: {...}}%% directive via mermaid_init().
  • Configured maxTextSize: 250000 in the client-side mermaid.initialize(mermaidConfig) block.
  • Added unit tests in tests/test_callflow_html.py validating directive configuration, custom overrides, and HTML file generation.

Type of change

  • Bug fix

Verification & Invariants

  • Read the CONTRIBUTING.md guide.
  • Reproduced the issue and identified the invariant.
  • Made the smallest fix necessary.
  • Added a regression test (test_mermaid_init_configures_max_text_size and test_write_callflow_html_includes_max_text_size in tests/test_callflow_html.py).
  • Kept the PR description synchronized with the final implementation.
  • Documented any limitations / unsupported cases explicitly.

How was this tested?

uv run pytest tests/test_callflow_html.py -q
uv run ruff check graphify/callflow_html.py tests/test_callflow_html.py
PATH="$(pwd)/.venv/bin:$PATH" uv run pre-commit run --all-files
uv run graphify update .

Graphify-specific checklist

  • I updated generated skill artifacts (uv run python -m tools.skillgen --bless) when changing their source fragments.
  • I confirmed that AST/structural extraction remains deterministic.
  • I reviewed changes for security implications.
  • I confirmed no API keys or local-only graph data are included.
  • (If applicable) I disclosed AI authorship in my commit messages.

…failure on large architectures

Mermaid v11 has a default browser text diagram limit of 50,000 characters.
When exporting architecture callflows for moderately complex projects or
sections with 40+ nodes and edges, the generated diagram definition exceeds
this limit, causing Mermaid to throw 'Error: Maximum text size in diagram exceeded'
and fail to render in the browser.

Configure maxTextSize: 250000 in both the Mermaid init directive (mermaid_init)
and the client-side execution config (mermaidConfig).

Co-authored-by: Antigravity <antigravity@google.com>
@github-actions

Copy link
Copy Markdown

Thanks for the pull request, @Gaurav-meena95. A maintainer will review it soon.

Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions.

A couple of things that speed up review: make sure the test suite passes on Python 3.11 and 3.13, and that the change keeps extraction deterministic.

@graphify-labs graphify-labs Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Graphify review View in Graphify

Nothing blocking · 8 possible issues to check · Merge confidence 5/5

8 possible issues to check · High impact

Mermaid init directives now default to a 250,000-character text limit and allow callers to set a different limit.

8 possible issues we couldn't confirm
  • The PR title says it prevents diagram rendering failures, but the code only raises a text-size limit and the description is empty · graphify/callflow_html.py:599
  • mermaid_init accepts any max_text_size value without validation, so a zero, negative or None value goes straight into the Mermaid config · graphify/callflow_html.py:602
  • The Mermaid maxTextSize check at line 377 would also pass for 2500000 or any other value starting with 250000 · tests/test_callflow_html.py:377
  • +5 more in Graphify

They don't change the score.

Code graph · 742 functions depend on this change
  • 1 function became more coupled. write_callflow_html() (8 callers).
  • 1 of 620 test files are affected by this change.
  • Gate, test list and every flagged function: in the Graphify check.

Reviewed c466199 · Full report in the Graphify check

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Architecture callflow Mermaid diagrams fail to render on larger codebases due to maxTextSize exceeded

1 participant