Repository navigation
fix: report Graphviz stderr when dot fails to render a diagram - #672
Merged
Merged
Conversation
pydot printed dot's stderr to stdout and raised an AssertionError that only carried the exit code, so the svg format, _repr_svg_, the command line and the Sphinx directive all failed with 'returned code: 1' and no reason. Every path now runs dot directly, feeding the DOT source on stdin, and raises GraphvizError with the requested format and what Graphviz wrote to stderr. A missing dot binary reports that it is not on PATH, with a link to the Graphviz download page. Fixes #649 Signed-off-by: Fernando Macedo <fgmacedo@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #672 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 52 53 +1
Lines 5685 5714 +29
Branches 896 900 +4
=========================================
+ Hits 5685 5714 +29
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Signed-off-by: Fernando Macedo <fgmacedo@gmail.com>
…stderr Signed-off-by: Fernando Macedo <fgmacedo@gmail.com> # Conflicts: # docs/releases/3.2.2.md
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #649
Why
When
dotrejects a graph, every library path that renders it (thesvgformat,_repr_svg_(), the CLI, the Sphinx directive) fails with"dot" with args [...] returned code: 1. The reason (Error: ...: syntax error in line 25 near ',') is printed to stdout by pydot 4.0.1 and never reaches the exception or the Sphinx warning (#649).What changes
dot -T<fmt>directly, with the DOT source on stdin, and raiseGraphvizErrorcarrying the format and Graphviz's stderr; the Sphinx directive reports the same text in its warning.dotthat is not onPATHraisesGraphvizErrorwith a link to the Graphviz download page; one that cannot run (permissions) or dies by a signal is reported as such.create()/write()(svg, png, dot, pdf checked);write_imageto.rawstill writes the DOT text without runningdot; no partial file is written and nothing reaches stdout on failure.GraphvizErrorsubclassesStateMachineErrorand is documented in the diagram page; release note added to 3.2.2.Evidence
Before (pydot) vs after, same malformed DOT:
ruff check,ruff format --check,mypy,pyrightandsphinx-buildclean (the{class}reference resolves).docs/images/readme_trafficlightmachine.pngwas regenerated by thegenerate-imageshook with the local Graphviz 16.1.0; the new path and pydot'swrite(format="png")produce the same bytes.Not verified
dot.exeresolution throughCreateProcess,CREATE_NO_WINDOW, and the.rawfile now being UTF-8 with\nwhere pydot used the locale encoding and text mode.syntax error ... near ';') is Graphviz's parser message and has been stable, but was not checked against 2.43 from the report.