Skip to content

fix: fall back to non-overlay analysis when diff-informed analysis is unavailable#3791

Open
sam-robson wants to merge 1 commit intomainfrom
sam-robson/overlay-fallback
Open

fix: fall back to non-overlay analysis when diff-informed analysis is unavailable#3791
sam-robson wants to merge 1 commit intomainfrom
sam-robson/overlay-fallback

Conversation

@sam-robson
Copy link
Copy Markdown
Contributor

When overlay analysis is enabled for a PR but diff-informed analysis fails (e.g. deleted branch, API error, too many changed files), the action previously continued with overlay-only analysis. This is an untested combination that can produce inaccurate results. Now we fall back to a full non-overlay analysis instead.

Risk assessment

For internal use only. Please select the risk level of this change:

  • Low risk: Changes are fully under feature flags, or have been fully tested and validated in pre-production environments and are highly observable, or are documentation or test only.

Which use cases does this change impact?

Workflow types:

  • Managed - Impacts users with dynamic workflows (Default Setup, Code Quality, ...).

Products:

  • Code Scanning - The changes impact analyses when analysis-kinds: code-scanning.
  • Code Quality - The changes impact analyses when analysis-kinds: code-quality.

Environments:

  • Dotcom - Impacts CodeQL workflows on github.com and/or GitHub Enterprise Cloud with Data Residency.
  • GHES - Impacts CodeQL workflows on GitHub Enterprise Server.

How did/will you validate this change?

  • Other - Manual code review. The change is a single conditional guard following established patterns in the same file. No unit tests due to the init-action entry point side-effect constraint, but the logic is minimal (3 conditions + mode revert).

If something goes wrong after this change is released, what are the mitigation and rollback strategies?

  • Rollback - Change can only be disabled by rolling back the release or releasing a new version with a fix.

How will you know if something goes wrong after this change is released?

  • Telemetry - I rely on existing telemetry or have made changes to the telemetry.
    • Dashboards - I will watch relevant dashboards for issues after the release. Consider whether this requires this change to be released at a particular time rather than as part of a regular release.

Are there any special considerations for merging or releasing this change?

  • No special considerations - This change can be merged at any time.

Merge / deployment checklist

  • Confirm this change is backwards compatible with existing workflows.
  • Consider adding a changelog entry for this change.
  • Confirm the readme and docs have been updated if necessary.

@github-actions github-actions bot added the size/XS Should be very easy to review label Mar 30, 2026
@sam-robson sam-robson force-pushed the sam-robson/overlay-fallback branch 2 times, most recently from 472336b to 8c82546 Compare March 30, 2026 09:50
@sam-robson sam-robson marked this pull request as ready for review March 30, 2026 13:11
@sam-robson sam-robson requested a review from a team as a code owner March 30, 2026 13:11
Copilot AI review requested due to automatic review settings March 30, 2026 13:11
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

Ensures the CodeQL init step avoids the unsupported “overlay-only” mode by falling back to a full non-overlay analysis when diff-informed analysis was expected but didn’t produce the pr-diff-range.json output.

Changes:

  • Add a hasDiffRangesJsonFile() helper to detect whether pr-diff-range.json was produced.
  • In init-action, revert overlayDatabaseMode to None when overlay is enabled, diff-informed analysis should have run, but the diff ranges file is missing.
  • Update the generated lib/init-action.js to reflect the TypeScript changes.

Reviewed changes

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

File Description
src/init-action.ts Adds a guard to revert overlay mode to non-overlay when diff-informed output is missing.
src/diff-informed-analysis-utils.ts Introduces hasDiffRangesJsonFile() helper for detecting persisted diff ranges output.
lib/init-action.js Generated build output reflecting the TypeScript changes (not reviewed).

Comment on lines +91 to +93
export function hasDiffRangesJsonFile(): boolean {
return fs.existsSync(actionsUtil.getDiffRangesJsonFilePath());
}
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

hasDiffRangesJsonFile is a new exported helper but there’s no unit test coverage for it, while this module already has AVA tests for other exported functionality. Adding a small test (file exists vs. not) would help prevent regressions in the fallback behavior that depends on this check.

Copilot uses AI. Check for mistakes.
@sam-robson sam-robson force-pushed the sam-robson/overlay-fallback branch from 8c82546 to 08f4ea7 Compare March 30, 2026 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XS Should be very easy to review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants