Skip to content

fix(cli): escape DOT strings and drop ANSI colors from --dot output - #2487

Open
rafal-hawrylak wants to merge 1 commit into
mainfrom
fix/dot-representation-escaping
Open

rafal-hawrylak wants to merge 1 commit into
mainfrom
fix/dot-representation-escaping

Conversation

@rafal-hawrylak

Copy link
Copy Markdown
Collaborator

Escape double quotes, backslashes and control characters in dotRepresentation node IDs, labels and edges so special characters cannot break Graphviz DOT syntax or trigger escString macro expansion. Always format DOT targets without ANSI color codes in interactive terminals and omit empty semicolon lines when a compiled graph has no nodes or no dependency edges so dot renders standalone-action and empty projects cleanly.

Escape double quotes, backslashes and control characters in dotRepresentation node IDs, labels and edges so special characters cannot break Graphviz DOT syntax or trigger escString macro expansion. Always format DOT targets without ANSI color codes in interactive terminals and omit empty semicolon lines when a compiled graph has no nodes or no dependency edges so dot renders standalone-action and empty projects cleanly.
@rafal-hawrylak
rafal-hawrylak requested a review from a team as a code owner November 24, 2026 15:02
@rafal-hawrylak
rafal-hawrylak requested review from Ford544, apilaskowski, mbiernacik and zaptot and removed request for a team and zaptot November 24, 2026 15:02
Comment thread cli/console_test.ts
);
});

test("printCompiledGraph prints DOT without ANSI escape sequences on an interactive terminal", () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Since dotRepresentation no longer takes an interactive flag, the first expect(dotRepresentation(graph)).equals(expected) already proves there is no ANSI output. Could we drop the process.stdout/isTTY/env patching? It is global state that is easy to leak if an assertion throws mid-test.

Comment thread cli/console.ts
* literal backslash (a line feed and a backslash followed by `n`) produce the same output, so two
* such names would share a node. BigQuery names cannot contain these characters.
*/
export function escapeDotString(value: string): string {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice docstring. Did you verify the trailing-backslash case (…\\") and the \N case with real dot -Tsvg? Might be worth a line in the PR description.

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.

2 participants