Skip to content

Emit valid SARIF URIs for AL code analysis paths containing spaces#2330

Open
aholstrup1 wants to merge 2 commits into
microsoft:mainfrom
aholstrup1:aholstrup1-fix-sarif-uri-encoding-spaces
Open

Emit valid SARIF URIs for AL code analysis paths containing spaces#2330
aholstrup1 wants to merge 2 commits into
microsoft:mainfrom
aholstrup1:aholstrup1-fix-sarif-uri-encoding-spaces

Conversation

@aholstrup1

Copy link
Copy Markdown
Collaborator

Why

When ProcessALCodeAnalysisLogs writes the SARIF file it put the raw workspace-relative path straight into results[].locations[0].physicalLocation.artifactLocation.uri. SARIF artifactLocation URIs must be valid URI references, but BCApps paths routinely contain spaces (for example 1.Setup Data/Foo.al, Contoso Helpers/...). A raw space is not a valid URI character, so github/codeql-action/upload-sarif logged thousands of '...' is not a valid URI warnings and alerts could fail to map back to their files.

What

Added a small ConvertTo-SarifArtifactUri helper that URI-encodes each /-separated path segment individually with [Uri]::EscapeDataString, preserving the / separators. So 1.Setup Data/Foo.al becomes 1.Setup%20Data/Foo.al and the path structure is unchanged. GenerateSARIFJson now runs the relative path through this helper only when writing the uri field; de-duplication still keys on the raw relative path, so dedup semantics are untouched.

Verified live on a BCApps PR: after the fix, 0 not a valid URI warnings.

Changes

  • Actions/ProcessALCodeAnalysisLogs/ProcessALCodeAnalysisLogs.psm1: new ConvertTo-SarifArtifactUri function (with comment-based help), exported from the module.
  • Actions/ProcessALCodeAnalysisLogs/ProcessALCodeAnalysisLogs.ps1: encode only the uri line in the result object.
  • Tests/ProcessALCodeAnalysisLogs.Test.ps1: an end-to-end test asserting the emitted uri is encoded (and that / is preserved), plus a unit-test Context for the new function. Tests pass on both Windows PowerShell 5 and PowerShell 7.
  • RELEASENOTES.md: release note describing the fix.

Notes

This is split out of a larger changeset into its own PR: it contains only the SARIF URI fix, no performance/scaling change to ProcessALCodeAnalysisLogs and no trackALAlertsInGitHub workspace-compilation change.

Copilot AI review requested due to automatic review settings July 24, 2026 12:16
@aholstrup1
aholstrup1 marked this pull request as ready for review July 24, 2026 12:18
@aholstrup1
aholstrup1 requested a review from a team as a code owner July 24, 2026 12:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes invalid SARIF artifact URIs for AL file paths containing spaces.

Changes:

  • Adds segment-wise URI encoding while preserving /.
  • Integrates encoding into SARIF generation.
  • Adds tests and release documentation.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
ProcessALCodeAnalysisLogs.psm1 Adds and exports URI conversion helper.
ProcessALCodeAnalysisLogs.ps1 Encodes SARIF artifact locations.
ProcessALCodeAnalysisLogs.Test.ps1 Tests URI encoding behavior.
RELEASENOTES.md Documents the fix.

Comment thread Actions/ProcessALCodeAnalysisLogs/ProcessALCodeAnalysisLogs.ps1 Outdated
Copilot AI review requested due to automatic review settings July 24, 2026 12:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

Tests/ProcessALCodeAnalysisLogs.Test.ps1:278

  • Specify UTF-8 explicitly when writing this JSON fixture. Set-Content defaults differ between Windows PowerShell 5 and PowerShell 7, while this repository's JSON-processing convention requires explicit UTF-8 encoding.
        $baseIssueContent | ConvertTo-Json -Depth 10 | Set-Content -Path $errorLogFile

Comment thread Tests/ProcessALCodeAnalysisLogs.Test.ps1
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