Skip to content

fix: skip SARIF upload when no findings - #153

Merged
ajianaz merged 1 commit into
developfrom
fix/conditional-sarif-upload
Jun 3, 2026
Merged

ajianaz merged 1 commit into
developfrom
fix/conditional-sarif-upload

Conversation

@ajianaz

@ajianaz ajianaz commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

CodeCora check shows ❌ fail on clean PRs because SARIF is always uploaded to GitHub Code Scanning — even when cora found zero issues.

Fix

Add a sarif-check step before upload that parses SARIF and counts findings. The upload-sarif step now only runs when findings > 0:

- name: Check SARIF for findings
  id: sarif-check
  run: |
    RESULTS=$(python3 -c "parse sarif, count results")
    echo "results=$RESULTS" >> "$GITHUB_OUTPUT"

- name: Upload SARIF to GitHub Code Scanning
  if: inputs.upload-sarif == 'true' && steps.sarif-check.outputs.results > 0
  uses: github/codeql-action/upload-sarif@v4

Behavior Change

Scenario Before After
PR with issues SARIF uploaded ✅, CodeCora ❌ (expected) SARIF uploaded ✅, CodeCora ❌ (expected)
Clean PR (no issues) SARIF uploaded ✅, CodeCora ❌ (false fail) SARIF skipped, no CodeCora check
LLM API failure SARIF empty, CodeCora ❌ (false fail) SARIF skipped, no CodeCora check

Files Modified

  • .github/actions/cora-review/action.yml — add sarif-check + conditional upload
  • .github/actions/cora-review-simple/action.yml — same fix

Co-Authored-By: codecoradev noreply@github.com

…n PRs)

Only upload SARIF to GitHub Code Scanning when the review actually found
issues. This prevents the CodeCora check from showing as 'failed' on clean
PRs where cora found no problems.

The upload-sarif step now depends on a sarif-check step that parses the
SARIF and outputs the findings count. The upload only runs when
findings > 0.

Co-Authored-By: codecoradev <noreply@github.com>
" 2>/dev/null || echo "0")
echo "results=$RESULTS" >> "$GITHUB_OUTPUT"
if [ "$RESULTS" -gt 0 ]; then
echo "SARIF contains $RESULTS finding(s) — will upload."
" 2>/dev/null || echo "0")
echo "results=$RESULTS" >> "$GITHUB_OUTPUT"
if [ "$RESULTS" -gt 0 ]; then
echo "SARIF contains $RESULTS finding(s) — will upload."
@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown

🔍 Cora AI Code Review

❌ Blocked — critical issues found.

🔴 Error (2)

  • .github/actions/cora-review-simple/action.yml:112 — The condition steps.sarif-check.outputs.results > 0 in GitHub Actions if expressions performs a string comparison, not a numeric one. While GitHub Actions does some type coercion, this is unreliable. For example, '9' > 0 is true but '10' > 0 may behave unexpectedly in string comparison contexts. The condition should explicitly use numeric comparison.
  • .github/actions/cora-review/action.yml:147 — The condition steps.sarif-check.outputs.results > 0 in GitHub Actions if expressions performs a string comparison, not a numeric one. While GitHub Actions does some type coercion, this is unreliable. For example, '9' > 0 is true but '10' > 0 may behave unexpectedly in string comparison contexts. The condition should explicitly use numeric comparison.

Review powered by cora-cli · BYOK · MIT

@ajianaz
ajianaz merged commit 08ad15c into develop Jun 3, 2026
7 of 8 checks passed
@ajianaz
ajianaz deleted the fix/conditional-sarif-upload branch June 4, 2026 06:03
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