Skip to content

[BUG][code-analyzer] Title: SARIF output contains results missing physicalLocation, causing GitHub Code Scanning upload failures #1970

@patrykacc

Description

@patrykacc

Have you tried to resolve this issue yourself first?

  • I confirm I have gone through the above steps and still have an issue to report.

Bug Description

When running sf code-analyzer run, the generated SARIF file includes several result objects that contain logicalLocations (e.g., Apex Class names) but are missing the physicalLocation property (the specific file URI and line numbers).

According to the SARIF specification and GitHub's ingestion requirements, a result intended for code scanning must be anchored to a physical artifact. When these "homeless" results are present, the GitHub upload-sarif action fails with the error: locationFromSarifResult: expected artifact location

Steps to Reproduce:
Run the analyzer on a Salesforce project:

Bash

sf code-analyzer run --target "./force-app" --workspace "./force-app" --output-file scan.sarif
Attempt to upload the resulting file to GitHub using github/codeql-action/upload-sarif.

The upload fails because of results like the following found in the SARIF:

JSON

{
"ruleId": "AvoidHardcodingConfigurations",
"locations": [
{
"logicalLocations": [
{
"fullyQualifiedName": "SomeClassName",
"kind": "class"
}
]
// ERROR: physicalLocation object is missing here
}
]
}
Expected Behavior:
Every result in the SARIF file should either:

Include a valid physicalLocation with a relative uri.

Be omitted from the SARIF output if no physical file location can be determined, as these results cannot be rendered in GitHub Code Scanning.

Actual Behavior:
The scanner produces results that only identify the logical structure (Apex Class), which causes the entire SARIF file to be rejected by GitHub's API.

Output / Logs

Steps To Reproduce

  1. Run: sf code-analyzer run --target "./force-app" --workspace "./force-app" --output-file scan.sarif
  2. Attempt to upload the resulting file to GitHub using github/codeql-action/upload-sarif.
  3. error about artifact location is being thrown

Expected Behavior

Include a valid physicalLocation with a relative uri allowing to process the report

Operating System

Ubuntu 24.04.4 LTS

Salesforce CLI Version

2.117.7

Code Analyzer Plugin (code-analyzer) Version

5.8.0

Node Version

20.19.6

Java Version

No response

Python Version

No response

Additional Context (Screenshots, Files, etc)

No response

Workaround

No response

Urgency

Low

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions