@@ -35,6 +35,7 @@ import { EnvVar } from "./environment";
3535import { Feature , featureConfig , Features } from "./feature-flags" ;
3636import {
3737 checkInstallPython311 ,
38+ checkPacksForOverlayCompatibility ,
3839 cleanupDatabaseClusterDirectory ,
3940 initCodeQL ,
4041 initConfig ,
@@ -766,6 +767,36 @@ async function run() {
766767 logger ,
767768 ) ;
768769
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+
769800 const tracerConfig = await getCombinedTracerConfig ( codeql , config ) ;
770801 if ( tracerConfig !== undefined ) {
771802 for ( const [ key , value ] of Object . entries ( tracerConfig . env ) ) {
0 commit comments