Fall back to non-overlay analysis when diff-informed analysis is unavailable#3791
Fall back to non-overlay analysis when diff-informed analysis is unavailable#3791sam-robson wants to merge 1 commit intomainfrom
Conversation
472336b to
8c82546
Compare
There was a problem hiding this comment.
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 whetherpr-diff-range.jsonwas produced. - In
init-action, revertoverlayDatabaseModetoNonewhen overlay is enabled, diff-informed analysis should have run, but the diff ranges file is missing. - Update the generated
lib/init-action.jsto 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). |
8c82546 to
08f4ea7
Compare
08f4ea7 to
3a6c216
Compare
c9b00bb to
5e930d3
Compare
mbg
left a comment
There was a problem hiding this comment.
Thanks for refactoring some of the logic out of init-action and into revertOverlayModeIfDiffInformedUnavailable, as well as adding tests!
I am still not convinced by the high-level approach here, though. If I see the flow correctly, the key events are:
- In
checkOverlayEnablement(inconfig-utils.ts), we perform most checks to determine whether overlay analysis should be enabled. - Afterwards, in
initConfig(also inconfig-utils.ts), we then callshouldPerformDiffInformedAnalysisif overlay analysis is enabled.shouldPerformDiffInformedAnalysisis primarily a check to see if we are analysing a pull request.- If diff-informed analysis should be enabled, then we add a query exclusion for
exclude-from-incremental.
- Back in
init-action.ts, we callcomputeAndPersistDiffRangesafterinitConfighas returned. This is what produces the file pointed at bygetDiffRangesJsonFilePath. - Your change then happens afterwards (outside the normal
try/catchblock), since you depend on checking whether thegetDiffRangesJsonFilePathfile exists or not.- You also again call
shouldPerformDiffInformedAnalysisto determine what should have happened. We could probably persist this information in the CodeQL Action state instead of recomputing it.
- You also again call
This seems a bit (unnecessarily) convoluted to me. I am wondering if:
- We can call
computeAndPersistDiffRangesas part of the diff-informed analysis check ininitConfiginconfig-utils.ts? Then the logic isn't spread across two locations and we can potentially also re-use the result ofgetDiffInformedAnalysisBranches. This would require us to movecomputeAndPersistDiffRangesfrominit-action.tsto somewhere more suitable. I don't see a reason for it to have to be ininit-action.ts, but we should check that calling it frominitConfigdoesn't cause any problems. - Then, we could perform the new check that is introduced here immediately afterwards in
initConfig. - We could also investigate whether both the initial diff-informed query enablement check and the new logic here could then be added to
checkOverlayEnablement
What do you think?
5e930d3 to
a26cb68
Compare
d8a6799 to
3d50556
Compare
758096a to
927f439
Compare
…is is unavailable
927f439 to
d75db24
Compare
Thanks! Pushed a refactor addressing these.
|
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:
Which use cases does this change impact?
Workflow types:
dynamicworkflows (Default Setup, Code Quality, ...).Products:
analysis-kinds: code-scanning.analysis-kinds: code-quality.Environments:
github.comand/or GitHub Enterprise Cloud with Data Residency.How did/will you validate this change?
If something goes wrong after this change is released, what are the mitigation and rollback strategies?
How will you know if something goes wrong after this change is released?
Are there any special considerations for merging or releasing this change?
Merge / deployment checklist