Repository navigation
fix(reporting): write reports for non-UTF-8 file names and keep SARIF URIs valid - #536
Merged
Merged
Conversation
… URIs valid On Linux, Python returns a file name that is not valid UTF-8 with surrogate escapes. Finding IDs, occurrence IDs and HTML issue keys hashed it as strict UTF-8, and ReporterBase.save, the CI scripts that re-render retained reports and the Tier 3 dataset writer encoded text the same way, so every written report format failed with UnicodeEncodeError. Hash with surrogatepass (identical bytes for valid text) and write unencodable characters as backslash escapes, which JSON reads back as the same name. The SARIF URI encodes the name's original bytes (caf%E9.md). SARIF artifactLocation.uri also stays a valid reference for more paths: - a colon in the first segment of a repository-relative path gets a "./" prefix, so "notes:v2.md" no longer parses as scheme "notes" (RFC 3986 section 4.2); - a path outside the workspace becomes an absolute file: URI instead of a bare file system path, with a UNC host percent-encoded; - a symlink in the workspace that points outside it keeps the link's repository-relative path instead of the target's absolute path, unless a ".." follows a symlinked directory. Paths that were already repository-relative keep the same URI. Fixes #525 Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rng1995
requested review from
chrisknvidia,
mosheabr and
rmalani-nv
as code owners
November 14, 2026 00:02
rng1995
enabled auto-merge (squash)
November 14, 2026 04:18
… POSIX only Windows collapses ".." in a path before it follows a symlink, so on the Windows job "dl\..\x.md" names the in-repository x.md and the reporter correctly emits a repository-relative URI. The test asserts the POSIX behavior, where the path reaches the symlink target's sibling. Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
Fixes #525. Follows #519 with the other cases where SkillEvaluator either failed to write its reports for an unusual file name or wrote a SARIF
artifactLocation.urithat does not identify the file.Non-UTF-8 file names (#525). On Linux, Python gives a file name that is not valid UTF-8 with surrogate escapes (
caf\udce9.mdfor the bytescaf\xe9.md). Finding IDs, occurrence IDs and HTML issue keys hashed that text as strict UTF-8, andReporterBase.saveencoded the rendered report the same way, so a defaultvalidaterun,-r json,markdown,sarifand-r sarifall stopped withUnicodeEncodeError. The same strict encoding was in the CI scripts that re-render retained reports (ci/secret_redaction.py,ci/run_tiers.py,ci/report_views.py,ci/native_reports.py) and in the Tier 3 dataset writer, which could leave a truncatedevals/evals.jsonin the skill.surrogatepass. Valid text encodes to the same bytes, so existing finding IDs do not change.backslashreplace, which only affects lone surrogates; JSON reads the escape back as the same name.ci/native_reports.pyhashes inline code with the same handler, so the CSP hashes match the bytes written.caf%E9.md.SARIF
artifactLocation.uri.notes:v2.mdat the repository rootnotes:v2.md, which parses as schemenotes./notes:v2.mdskills/a:b.mdskills/a:b.md/tmp/x.md, orC:/x.mdon Windows (schemec)file:///tmp/x.md,file:///C:/x.mdUnicodeEncodeErrorcaf%E9.mdPaths that were already repository-relative keep byte-identical URIs; this was checked before and after over several thousand path and root combinations on macOS and Linux. A
..after a symlinked directory keeps the resolved target, because the lexical path would name a different file.Not changed:
_resolve_artifact_pathstill treats\as a separator on every host, as finding IDs and declared plugin paths do, so a POSIX file literally nameda\b.mdstill maps toa/b.md.Verification
I am familiar with the Contributing Guidelines
Added or updated focused tests
Updated documentation for user-visible changes
Ran
make lintRan
make testRan
make buildDid not add credentials, private datasets, or proprietary benchmark content
New tests in
tests/reporting/test_reporters.py,tests/ci/test_secret_redaction.pyandtests/tier3/test_dataset_baseline_fairness.py. Each fails when its fix is reverted. The tests that need POSIX file names or symlinks are skipped where those are unavailable.tests/reporting,tests/models,tests/ci/test_secret_redaction.py,tests/ci/test_report_views.pyandtests/tier3/test_dataset_baseline_fairness.py(macOS, Python 3.14,-n 4): 2820 passed, 2 failed.test_validate_tier3_writes_the_same_report_pairfails on main too.test_missing_chart_asset_keeps_the_report_and_visible_fallbackspasses when run alone, with and without this change.Linux (Python 3.12 container) with a real
caf\xe9.mdin a skill:validatewith no-r, with--verbose, and with-rset tojson,markdown,html,sarif,cliandjson,markdown,sarifwrites every report. The JSON and SARIF parse, and the SARIF holdsskills/s/caf%E9.md. On main every one of those runs exceptcliand--verbosestopped withUnicodeEncodeError.ruff checkpasses onsrc/,ci/and the changed tests. I ran the test subsets above rather than the fullmake test. No docs describe SARIF URI encoding or this failure, so none changed.Release Impact
CHANGELOG.md🤖 Generated with Claude Code