Repository navigation
An input with no graph in it is nothing to draw: exit 0, as Graphviz's dot; it was 1 - #156
Merged
Merged
Conversation
…s dot; it was 1 For an input that is empty, blank or comments alone, Graphviz's dot renders nothing and exits 0: nothing on either stream, and with -o no file made and the one at the path left as it was (measured with dot 16.1.1). This command exited 1 with "parse input: graphviz: no graph was produced", and its tests held it to that. run now reads and parses the input before it picks where to write, and a text go-graphviz says holds no graph (cgraph.ErrNoGraph) ends there with status 0. A text that cannot be read is a failure as before. The check for a nil graph after a parse without error is gone: go-graphviz returns none. go-graphviz is required at the commit on its main that has the error, 1880f86, which also carries its fixes since v0.6.0. The contract test holds each case to the status, the two streams and the directory, and to Graphviz's dot where the test has one; the fuzz target holds that an exit 0 with nothing written is a text with no graph in it, and only that. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Signed-off-by: closer-claudio <claudio@farcloser.world>
closer-claudio
enabled auto-merge
November 23, 2026 02:57
Contributor
Author
|
Reviewed at 1083363 |
apostasie
approved these changes
Nov 23, 2026
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.
dotexited 1 on an input with no graph in it: empty, blank, or comments alone. Graphviz'sdotrenders nothing for such an input and exits 0. This command now does the same.This breaks a caller that relied on the failure: a pipeline that fed
dotnothing got status 1 and now gets status 0 and no output.What Graphviz does
Measured with Graphviz's
dot16.1.1 on an empty input, a blank one, a line comment, a block comment and a preprocessor line:-oto a new path, no file is made;-oover an existing file, the file is left as it was.A text it cannot read (
digraph { a ->, a bare word) is exit 1.The change
run(cmd/dot/main.go) reads and parses the input before it decides where to write. A text that holds no graph ends there with status 0: nothing is written, and under-ono temporary file is made, so nothing is renamed over the output.cgraph.ErrNoGraph(ParseBytes says when a text holds no graph: cgraph.ErrNoGraph, apart from a syntax error go-graphviz#248), which is held to Graphviz'sdotthere. The module is required at the commit on its main that carries it, 1880f86 (v0.6.1-0.20261122214648-1880f8661dd1), which also brings its fixes since v0.6.0: a JPEG is white where the page is transparent, a string of quotes is written whole, a dashed edge far from the page is drawn in the page's memory.Evidence
TestATextWithNoGraphIsNothingToDraw(cmd/dot/contract_test.go) runs the built command on the five texts above, in three formats, to standard output, to a new path and over an existing file: status 0, both streams empty, the directory as it was. Where the test has a Graphvizdot(DOT_ORACLE), it holds the same texts to it. Two texts that cannot be read stay exit 1 with a parse error. It replacesTestEmptyInputIsAnErrorand the "empty input" row of the contract table, which held the old status.FuzzInputholds the line from the other side: an exit 0 with nothing on standard output is a text go-graphviz says holds no graph, and only that. Its corpus passes, and 30 seconds of fuzzing on four workers found nothing.just lintandjust testpass; the oracle test (TestDOTIsGraphvizsDOTBothWays) passes against Graphviz'sdot16.1.1.