Skip to content

fix(reporting): write reports for non-UTF-8 file names and keep SARIF URIs valid - #536

Merged
rng1995 merged 4 commits into
mainfrom
naren/report-path-encoding-fixes
Nov 14, 2026
Merged

rng1995 merged 4 commits into
mainfrom
naren/report-path-encoding-fixes

Conversation

@rng1995

@rng1995 rng1995 commented Nov 14, 2026

Copy link
Copy Markdown
Collaborator

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.uri that 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.md for the bytes caf\xe9.md). Finding IDs, occurrence IDs and HTML issue keys hashed that text as strict UTF-8, and ReporterBase.save encoded the rendered report the same way, so a default validate run, -r json,markdown,sarif and -r sarif all stopped with UnicodeEncodeError. 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 truncated evals/evals.json in the skill.

  • Hashes use surrogatepass. Valid text encodes to the same bytes, so existing finding IDs do not change.
  • Writers use backslashreplace, which only affects lone surrogates; JSON reads the escape back as the same name. ci/native_reports.py hashes inline code with the same handler, so the CSP hashes match the bytes written.
  • The SARIF URI encodes the name's original bytes: caf%E9.md.

SARIF artifactLocation.uri.

Path Before After
notes:v2.md at the repository root notes:v2.md, which parses as scheme notes ./notes:v2.md
skills/a:b.md skills/a:b.md unchanged
Outside the workspace /tmp/x.md, or C:/x.md on Windows (scheme c) file:///tmp/x.md, file:///C:/x.md
Symlink in the repository pointing outside it the target's absolute path the link's repository-relative path
Non-UTF-8 name UnicodeEncodeError caf%E9.md

Paths 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_path still treats \ as a separator on every host, as finding IDs and declared plugin paths do, so a POSIX file literally named a\b.md still maps to a/b.md.

Verification

  • I am familiar with the Contributing Guidelines

  • Added or updated focused tests

  • Updated documentation for user-visible changes

  • Ran make lint

  • Ran make test

  • Ran make build

  • Did not add credentials, private datasets, or proprietary benchmark content

  • New tests in tests/reporting/test_reporters.py, tests/ci/test_secret_redaction.py and tests/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.py and tests/tier3/test_dataset_baseline_fairness.py (macOS, Python 3.14, -n 4): 2820 passed, 2 failed. test_validate_tier3_writes_the_same_report_pair fails on main too. test_missing_chart_asset_keeps_the_report_and_visible_fallbacks passes when run alone, with and without this change.

  • Linux (Python 3.12 container) with a real caf\xe9.md in a skill: validate with no -r, with --verbose, and with -r set to json, markdown, html, sarif, cli and json,markdown,sarif writes every report. The JSON and SARIF parse, and the SARIF holds skills/s/caf%E9.md. On main every one of those runs except cli and --verbose stopped with UnicodeEncodeError.

  • ruff check passes on src/, ci/ and the changed tests. I ran the test subsets above rather than the full make test. No docs describe SARIF URI encoding or this failure, so none changed.

Release Impact

  • No user-visible release note needed
  • Updated CHANGELOG.md

🤖 Generated with Claude Code

… 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
rng1995 enabled auto-merge (squash) November 14, 2026 04:18
rng1995 and others added 2 commits November 13, 2026 20: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>
@rng1995
rng1995 merged commit 550bb73 into main Nov 14, 2026
27 checks passed
@rng1995
rng1995 deleted the naren/report-path-encoding-fixes branch November 14, 2026 04:31
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.

[BUG]: Reports crash on Linux when a skill file name is not valid UTF-8

1 participant