@@ -35,6 +35,7 @@ import { EnvVar } from "./environment";
35
35
import { Feature , featureConfig , Features } from "./feature-flags" ;
36
36
import {
37
37
checkInstallPython311 ,
38
+ checkPacksForOverlayCompatibility ,
38
39
cleanupDatabaseClusterDirectory ,
39
40
initCodeQL ,
40
41
initConfig ,
@@ -733,6 +734,36 @@ async function run() {
733
734
logger ,
734
735
) ;
735
736
737
+ // To check custom query packs for compatibility with overlay analysis, we
738
+ // need to first initialize the database cluster, which downloads the
739
+ // user-specified custom query packs. But we also want to check custom query
740
+ // pack compatibility first, because database cluster initialization depends
741
+ // on the overlay database mode. The solution is to initialize the database
742
+ // cluster first, check custom query pack compatibility, and if we need to
743
+ // revert to `OverlayDatabaseMode.None`, re-initialize the database cluster
744
+ // with the new overlay database mode.
745
+ if (
746
+ config . augmentationProperties . overlayDatabaseMode !==
747
+ OverlayDatabaseMode . None &&
748
+ ! ( await checkPacksForOverlayCompatibility ( codeql , config , logger ) )
749
+ ) {
750
+ logger . info (
751
+ "Reverting overlay database mode to None due to incompatible packs." ,
752
+ ) ;
753
+ config . augmentationProperties . overlayDatabaseMode =
754
+ OverlayDatabaseMode . None ;
755
+ cleanupDatabaseClusterDirectory ( config , logger ) ;
756
+ await runDatabaseInitCluster (
757
+ databaseInitEnvironment ,
758
+ codeql ,
759
+ config ,
760
+ sourceRoot ,
761
+ "Runner.Worker.exe" ,
762
+ qlconfigFile ,
763
+ logger ,
764
+ ) ;
765
+ }
766
+
736
767
const tracerConfig = await getCombinedTracerConfig ( codeql , config ) ;
737
768
if ( tracerConfig !== undefined ) {
738
769
for ( const [ key , value ] of Object . entries ( tracerConfig . env ) ) {
0 commit comments