Skip to content

internal/graph: escape source filenames in DOT labels - #1032

Open
jabrailkhalil wants to merge 13 commits into
google:mainfrom
jabrailkhalil:fix/dot-source-filenames
Open

jabrailkhalil wants to merge 13 commits into
google:mainfrom
jabrailkhalil:fix/dot-source-filenames

Conversation

@jabrailkhalil

@jabrailkhalil jabrailkhalil commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Source filenames containing double quotes can break the quoted DOT node label at file/line granularity. Apply the existing DOT escaping after taking the basename.

The existing TestComposeWithNamesThatNeedEscaping now includes one quoted filename with a line/column suffix and uses its existing golden. I removed the additional newline/backslash filename cases as requested; TestEscapeForDot already covers the helper's supported characters. The production fix remains one line.

Addresses the filename portion of #1020; sample-tag escaping is separate (#1008).

Current head e2366c6 was validated against main 7bae8d8c in this Linux run: the unchanged full test.sh and fresh root/browser race tests pass on both trees. Chrome tests execute without browser skips; four existing root platform skips remain on both. With only the test/golden changes applied to main, the quoted-filename golden fails while all helper cases pass.

Windows graph tests, graph race tests, vet and formatting pass. Earlier full-Windows PE/DWARF failures also occurred on main and are not claimed fixed. This is author validation, not the full upstream OS/Go matrix; upstream CI authorization and review remain required.

Comment thread internal/graph/dotgraph_test.go Outdated
compareGraphs(t, buf.Bytes(), "compose7.dot")
}

func TestComposeWithFilenamesThatNeedEscaping(t *testing.T) {

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.

Can we just add these test cases to the TestComposeWithNamesThatNeedEscaping test above?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Consolidated the filename cases into TestComposeWithNamesThatNeedEscaping and removed the separate multilinePrintableName test. The compose golden cases cover quotes, newlines and literal backslashes, including line/column labels; the backslash case is skipped on Windows because it is a path separator there. Updated in 0424813. The root Go suite, graph race test and graph vet pass.

Comment thread internal/graph/dotgraph_test.go Outdated
}
}

func TestMultilinePrintableNameWithFilenamesThatNeedEscaping(t *testing.T) {

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.

Does this test buy us any coverage over the compose test above? Maybe just add the relevant test cases there?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed the redundant direct-helper test; its filename cases now run through the compose/golden test, as requested. The production fix is unchanged.

@jabrailkhalil

Copy link
Copy Markdown
Contributor Author

I consolidated the filename regressions into the existing compose-test table as requested and updated this branch from main. On current head fdc18ddac53f, both the root and browsertests modules pass go test ./... -count=1 on Linux with Go 1.26.7. The consolidated filename cases also fail when the production escaping is reverted. The current upstream CI/security workflows are waiting for maintainer approval; could you approve those runs when reviewing this revision?

Comment thread internal/graph/dotgraph_test.go Outdated
name: "filenames with quotes and newlines",
src: NodeInfo{Name: "src", File: `src/file"name.cc`, Lineno: 10, Columnno: 2},
dest: NodeInfo{File: "src/file\nname.cc"},
want: "compose_filenames.dot",

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.

Can we use one file per test function like before? When I mentioned consolidating I didn't mean just handling two files in the same funciton.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I restored one golden file per test function. Quote/newline filenames now extend the existing escaping-name graph and share compose7.dot; I removed the redundant filename golden. Literal backslashes have one separate compose test because Windows treats them as path separators. The production fix is unchanged. Linux graph tests, race tests, vet, gofmt, and Graphviz parsing pass; both regressions fail if filename escaping is removed. The quote/newline test also passes when the cross-compiled test binary is run on Windows, with the backslash test skipped as intended.

@jabrailkhalil

Copy link
Copy Markdown
Contributor Author

Integrated current main 7bae8d8c in 95895448 to clear BEHIND without adding feature scope.

The graph package tests and scoped go vet pass. The backslash-filename case retains its existing Windows skip; it was not executed as a Linux filesystem test.

Fresh validation uses Windows Go 1.26.0, inherited from current main. The full Windows suite is not green: the three PE/DWARF mapping subcases also fail on clean current main in the same environment. The initial run additionally lacked the external diff executable; it is not treated as a source regression. Browser modules retain their x86-64 Linux guards and skip execution on Windows: compilation is not a new Linux/browser/race validation. No existing assertions, timing thresholds, platform guards or dependency versions were weakened. Current-head upstream CI and maintainer review are still needed.

Could a maintainer approve the new-head workflow and review the integration?

@jabrailkhalil

jabrailkhalil commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor Author

Validated unchanged head 95895448dfd405a9b55bd5c6c1286ff75b846bf1 against main 7bae8d8c4c9ebc3886a79f796fbde65b7e1316f8 in an isolated author-fork Linux run. Ubuntu 24.04 / Go 1.26.8 / Chrome 154, with Graphviz and LLVM available. The complete, unmodified test.sh passed, including both modules, race/coverage, staticcheck 2026.2.1, the upstream golangci-lint v2.14.0 commands, vet and formatting. Fresh go test -race -count=1 -json ./... also passed in each module; no browser test was skipped. The four pre-existing root test/subtest platform skips are retained on both head and main.

Both filename-escaping regressions actually execute and pass on Linux, including the literal-backslash case. With only the regression test/golden changes applied to main, both fail with the expected unescaped DOT-label differences; no production file was changed in the control.

Main passed the same Linux commands. Module manifests, checksums and test.sh are byte-identical between the compared trees. The diagnostic workflow exists only on a separate branch in my fork; this PR head, assertions, deadlines and upstream workflow were not changed. This is author validation on one Linux/Go version, not the full upstream OS/Go matrix or a replacement for required Google CI/review; the earlier Windows failures below are not relabeled as passing.

Update October 12: GitHub now reports this historical matrix job as completed/SUCCESS, consistent with its raw evidence. Current-head validation is linked in the updated PR description.

Could a maintainer authorize the upstream workflow and review the current-head integration?

Comment thread internal/graph/dotgraph_test.go Outdated
compareGraphs(t, buf.Bytes(), "compose7.dot")
}

func TestComposeWithFilenamesWithBackslashes(t *testing.T) {

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.

Can this case be a part of TestComposeWithNamesThatNeedEscaping?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in cb195a7: the backslash-label assertion is now part of TestComposeWithNamesThatNeedEscaping, and the separate test/golden is removed. Quote/newline coverage still runs on Windows. Linux passes; both the golden check and backslash assertion fail against unchanged main production code.

@aalexand

aalexand commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

@jabrailkhalil Having reviewed a few of your PRs, they require quite a few iterations and have substantial amount of AI generated traffic that appears to be unreviewed / unshaped by the author. Can I ask you to either curate the changes more to make them more concise and suitable in their size for their value, or to stop contributing?

Related: Are you an active pprof user? I updated CONTRIBUTING.md a little to clarify the guidelines. In particular, we expect most contributions to be from active pprof users contributing fixes for the problems they encounter in their work. We are less interested in contributions that just go over the backlog to fix things: Some of those are lower priority and they are not worth working on (either for authors or reviewers) before there is enough user feedback to prioritize them.

@jabrailkhalil

Copy link
Copy Markdown
Contributor Author

Thanks for the direct feedback. I have shortened the description and confined this revision to the requested test consolidation; the production fix is still one line. The new Linux head/main validation passes, including the negative control.

These PRs were based on existing issues; I do not have a specific first-hand workflow report to add, and will not present them as one. I will keep further replies concise and will not start additional pprof backlog work without a maintainer go-ahead.

Comment thread internal/graph/dotgraph_test.go Outdated
compareGraphs(t, buf.Bytes(), "compose7.dot")

// Backslashes are filename characters only on Unix.
if filepath.Separator != '\\' {

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.

We have the TestEscapeForDot() test that checks the helper for all supported characters.

Maybe in this test it's enough to just test with the double quote? Other characters are supported because the common helper is used, so I think this code / case do not add much.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in e2366c6: I kept only the quoted-filename regression in the existing compose/golden test and removed the additional newline/backslash cases. The helper tests are unchanged. Full Linux validation passes on head and main; the tests-only negative control fails the filename golden on main while TestEscapeForDot still passes. Run.

@aalexand

Copy link
Copy Markdown
Collaborator

Thanks for the direct feedback. I have shortened the description and confined this revision to the requested test consolidation; the production fix is still one line. The new Linux head/main validation passes, including the negative control.

These PRs were based on existing issues; I do not have a specific first-hand workflow report to add, and will not present them as one. I will keep further replies concise and will not start additional pprof backlog work without a maintainer go-ahead.

SG - thanks!

@codecov-commenter

codecov-commenter commented Oct 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.43%. Comparing base (1facf8f) to head (37811fb).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1032      +/-   ##
==========================================
+ Coverage   73.42%   73.43%   +0.01%     
==========================================
  Files          46       46              
  Lines        7936     7936              
==========================================
+ Hits         5827     5828       +1     
+ Misses       2086     2085       -1     
  Partials       23       23              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jabrailkhalil

Copy link
Copy Markdown
Contributor Author

Thanks for the review and approval. I have left the reviewed head dacfc9e6 unchanged; its upstream Linux, macOS and Windows checks are green, and GitHub reports no merge conflict. Could a maintainer complete the merge when convenient? I am not adding further scope to this PR.

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.

3 participants