@@ -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 ,
@@ -766,6 +767,36 @@ async function run() {
766
767
logger ,
767
768
) ;
768
769
770
+ // To check custom query packs for compatibility with overlay analysis, we
771
+ // need to first initialize the database cluster, which downloads the
772
+ // user-specified custom query packs. But we also want to check custom query
773
+ // pack compatibility first, because database cluster initialization depends
774
+ // on the overlay database mode. The solution is to initialize the database
775
+ // cluster first, check custom query pack compatibility, and if we need to
776
+ // revert to `OverlayDatabaseMode.None`, re-initialize the database cluster
777
+ // with the new overlay database mode.
778
+ if (
779
+ config . augmentationProperties . overlayDatabaseMode !==
780
+ OverlayDatabaseMode . None &&
781
+ ! ( await checkPacksForOverlayCompatibility ( codeql , config , logger ) )
782
+ ) {
783
+ logger . info (
784
+ "Reverting overlay database mode to None due to incompatible packs." ,
785
+ ) ;
786
+ config . augmentationProperties . overlayDatabaseMode =
787
+ OverlayDatabaseMode . None ;
788
+ cleanupDatabaseClusterDirectory ( config , logger ) ;
789
+ await runDatabaseInitCluster (
790
+ databaseInitEnvironment ,
791
+ codeql ,
792
+ config ,
793
+ sourceRoot ,
794
+ "Runner.Worker.exe" ,
795
+ qlconfigFile ,
796
+ logger ,
797
+ ) ;
798
+ }
799
+
769
800
const tracerConfig = await getCombinedTracerConfig ( codeql , config ) ;
770
801
if ( tracerConfig !== undefined ) {
771
802
for ( const [ key , value ] of Object . entries ( tracerConfig . env ) ) {
0 commit comments