Skip to content

Fix CodeQL workflow: correct alert collection bug and improve fork PR handling#249

Merged
knoepfel merged 9 commits intoFramework-R-D:mainfrom
greenc-FNAL:bugfix/codeql-pr-comments
Jan 13, 2026
Merged

Fix CodeQL workflow: correct alert collection bug and improve fork PR handling#249
knoepfel merged 9 commits intoFramework-R-D:mainfrom
greenc-FNAL:bugfix/codeql-pr-comments

Conversation

@greenc-FNAL
Copy link
Copy Markdown
Contributor

  • Fix CodeQL workflow: correct alert collection bug and improve fork PR handling
  • Improve error message clarity for missing comment file
  • Add blank line after headling
  • Improve API handling for alerts
  • Really enable PR comments this time

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a critical bug in the CodeQL workflow where alerts were not being properly collected, and introduces a new workflow architecture to enable PR comments for fork-based pull requests. The fix addresses an indentation error that caused alerts to be skipped, and adds support for multiple alert location formats from the GitHub API.

Changes:

  • Fixed critical indentation bug in collect_alerts() that prevented alerts from being added to buckets
  • Enhanced alert location parsing to handle both SARIF physicalLocation format and flat API format
  • Introduced a new codeql-comment.yaml workflow using workflow_run trigger to post comments with elevated permissions
  • Replaced inline PR comment posting with artifact-based approach in codeql-analysis.yaml
  • Updated documentation to explain the new fork PR handling workflow

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
scripts/check_codeql_alerts.py Fixed critical bug where alerts were not appended to buckets; added support for flat API location format
.github/workflows/codeql-comment.yaml New privileged workflow for posting PR comments via workflow_run trigger
.github/workflows/codeql-analysis.yaml Refactored to upload PR comment data as artifacts instead of posting comments directly
.github/CodeQL-README.md Added documentation section explaining fork PR handling and alert viewing

@greenc-FNAL
Copy link
Copy Markdown
Contributor Author

@phlexbot python-fix

@github-actions
Copy link
Copy Markdown
Contributor

Automatic Python linting fixes pushed (commit e51ef97).
⚠️ Note: Some issues may require manual review and fixing.

@greenc-FNAL greenc-FNAL force-pushed the bugfix/codeql-pr-comments branch from e51ef97 to f1a2efc Compare January 13, 2026 16:03
Copilot AI and others added 9 commits January 13, 2026 13:49
… handling

- Fixed critical bug in check_codeql_alerts.py where alerts with valid locations were not being added to results
- Added validation in workflow to handle missing comment_path gracefully
- Enhanced error messages for fork PRs with instructions on viewing alerts
- Updated CodeQL-README.md with comprehensive documentation for viewing alerts from fork PRs

Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com>
Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@greenc-FNAL greenc-FNAL force-pushed the bugfix/codeql-pr-comments branch from 13f5b5d to 66d86ea Compare January 13, 2026 19:50
@knoepfel knoepfel merged commit d3cc3ed into Framework-R-D:main Jan 13, 2026
34 checks passed
@greenc-FNAL greenc-FNAL deleted the bugfix/codeql-pr-comments branch January 20, 2026 23:17
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.

4 participants