Skip to content

fix: correct regex over-matching, missing pagination, and ignored exit codes#9

Draft
NormandErwan wants to merge 4 commits into
mainfrom
claude/fix-xrefmaps-audit-issues-8Tvrf
Draft

fix: correct regex over-matching, missing pagination, and ignored exit codes#9
NormandErwan wants to merge 4 commits into
mainfrom
claude/fix-xrefmaps-audit-issues-8Tvrf

Conversation

@NormandErwan
Copy link
Copy Markdown
Owner

@NormandErwan NormandErwan commented May 3, 2026

What was wrong and what changed

Regex stripping too many characters from xref map files

The code was removing the colon from any digit-colon sequence (0:, 1:, 2:, …) in the raw YAML before parsing, even though only 0: is problematic (YAML treats it as a mapping key).

For example, a reference like "SomeType.Method(Int32):SomeParam" would have its 2: silently stripped to "SomeType.Method(Int32)SomeParam", producing a wrong href.

Fix: the regex now only matches 0:, leaving all other digit-colon sequences untouched.


Unity Releases API silently returning only the first 25 versions

The workflow fetched Unity versions with a hard-coded limit=25 and no paging, so any releases beyond the first 25 were silently ignored — no error, no warning, just missing xref maps.

For example, if Unity has 40 supported versions, only the 25 most recent ones would ever get an xref map generated.

Fix: the fetch now loops with an increasing offset until the API returns an empty page, collecting every version before processing.


DocFX exit code was never checked

RunCommand returned nothing, so a DocFX failure (non-zero exit code) was invisible to the caller. The code only noticed something went wrong if the output file happened to be missing afterwards — a much weaker signal.

For example, DocFX could fail mid-run, produce a partial file, and the tool would happily try to parse and publish it.

Fix: RunCommand now returns the process exit code. If DocFX exits non-zero, the error is logged immediately and that version is skipped.


PowerShell step not propagating the tool's exit code

In the GitHub Actions workflow, the dotnet … UnityXrefMaps.dll command runs inside a PowerShell script. PowerShell does not automatically fail the step when a command inside it exits non-zero, so a tool failure would be silently swallowed and the step would appear green.

Fix: added if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } right after the dotnet command so a failure correctly marks the CI step as failed.


Test plan

  • dotnet build --configuration Release compiles without errors
  • dotnet test passes
  • Trigger the unity-xref-maps workflow manually and confirm versions beyond 25 appear in the matrix
  • Verify a DocFX failure now surfaces as a failed CI step

https://claude.ai/code/session_0145GzJVvweE69KcFn9j1WWB

- XrefMapService: narrow ZeroStringsRegex from `(\d):` to `\b0:` so
  only the YAML-crashing `0:` pattern is stripped, not every digit
  before a colon; update replacement from "$1" to "0" (no capture group)
- Utils.RunCommand: return process.ExitCode so callers can observe
  non-zero results
- BuildCommand: check DocFX exit code and log/continue on failure
- unity-xref-maps.yml: paginate Unity Releases API with offset loop to
  avoid silent truncation at limit=25; propagate dotnet tool exit code
  with `if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }`

https://claude.ai/code/session_0145GzJVvweE69KcFn9j1WWB
@NormandErwan NormandErwan changed the title fix: address P1 audit issues — regex scope, pagination, exit codes fix: correct regex over-matching, missing pagination, and ignored exit codes May 3, 2026
claude added 2 commits May 3, 2026 19:38
XrefMapServiceTests:
- Load_ZeroColonAtWordBoundary_IsStripped: verifies `0: value` (which
  would crash the YAML deserializer) is pre-processed correctly
- Load_NonZeroDigitColon_IsPreserved: verifies that `data1:field` in a
  string value keeps its colon; the old `(\d):` regex stripped it

UtilsTests:
- RunCommand_SuccessfulProcess_ReturnsZero / _FailingProcess_ReturnsNonZero:
  verify that RunCommand surfaces the process exit code; both tests fail
  to compile against the unfixed code because RunCommand returned void

https://claude.ai/code/session_0145GzJVvweE69KcFn9j1WWB
- XrefMapService: narrow ZeroStringsRegex from `(\d):` to `\b0:` so
  only the YAML-crashing `0:` pattern is stripped, not every digit
  before a colon; update replacement from "$1" to "0" (no capture group)
- Utils.RunCommand: return process.ExitCode so callers can observe
  non-zero results
- BuildCommand: check DocFX exit code and log/continue on failure
- unity-xref-maps.yml: paginate Unity Releases API with offset loop to
  avoid silent truncation at limit=25; propagate dotnet tool exit code
  with `if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }`

https://claude.ai/code/session_0145GzJVvweE69KcFn9j1WWB
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