Skip to content

Commit e483d11

Browse files
committed
fix: fall back to non-overlay analysis when diff-informed analysis is unavailable
1 parent 9d3ec57 commit e483d11

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/init-action.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ import {
4040
import {
4141
getDiffInformedAnalysisBranches,
4242
getPullRequestEditedDiffRanges,
43+
readDiffRangesJsonFile,
44+
shouldPerformDiffInformedAnalysis,
4345
writeDiffRangesJsonFile,
4446
} from "./diff-informed-analysis-utils";
4547
import { EnvVar } from "./environment";
@@ -438,6 +440,22 @@ async function run(startedAt: Date) {
438440
return;
439441
}
440442

443+
// If overlay is enabled and diff-informed analysis should have run but
444+
// failed to produce output, revert to non-overlay analysis. Overlay
445+
// without diff-informed is an untested combination that can produce
446+
// inaccurate results.
447+
if (
448+
config.overlayDatabaseMode === OverlayDatabaseMode.Overlay &&
449+
(await shouldPerformDiffInformedAnalysis(codeql, features, logger)) &&
450+
readDiffRangesJsonFile(logger) === undefined
451+
) {
452+
logger.warning(
453+
"Diff-informed analysis is not available for this pull request. " +
454+
`Reverting overlay database mode to ${OverlayDatabaseMode.None}.`,
455+
);
456+
config.overlayDatabaseMode = OverlayDatabaseMode.None;
457+
}
458+
441459
let overlayBaseDatabaseStats: OverlayBaseDatabaseDownloadStats | undefined;
442460
let dependencyCachingStatus: DependencyCacheRestoreStatusReport | undefined;
443461
try {

0 commit comments

Comments
 (0)