Skip to content

Commit ee2d78f

Browse files
committed
Add warning when using unsupported CLI version
This adds a warning when the user is using an unsupported version of the CodeQL CLI. The warning is shown once per session, and only if the version is older than the oldest supported version.
1 parent baea365 commit ee2d78f

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

extensions/ql-vscode/src/codeql-cli/cli.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1737,6 +1737,10 @@ export function shouldDebugCliServer() {
17371737
}
17381738

17391739
export class CliVersionConstraint {
1740+
// The oldest version of the CLI that we support. This is used to determine
1741+
// whether to show a warning about the CLI being too old on startup.
1742+
public static OLDEST_SUPPORTED_CLI_VERSION = new SemVer("2.7.6");
1743+
17401744
/**
17411745
* CLI version where building QLX packs for remote queries is supported.
17421746
* (The options were _accepted_ by a few earlier versions, but only from

extensions/ql-vscode/src/extension.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
activate as archiveFilesystemProvider_activate,
2525
zipArchiveScheme,
2626
} from "./common/vscode/archive-filesystem-provider";
27-
import { CodeQLCliServer } from "./codeql-cli/cli";
27+
import { CliVersionConstraint, CodeQLCliServer } from "./codeql-cli/cli";
2828
import {
2929
CliConfigListener,
3030
DistributionConfigListener,
@@ -408,6 +408,28 @@ export async function activate(
408408
codeQlExtension.cliServer.addVersionChangedListener((ver) => {
409409
telemetryListener.cliVersion = ver;
410410
});
411+
412+
let unsupportedWarningShown = false;
413+
codeQlExtension.cliServer.addVersionChangedListener((ver) => {
414+
if (!ver) {
415+
return;
416+
}
417+
418+
if (unsupportedWarningShown) {
419+
return;
420+
}
421+
422+
if (CliVersionConstraint.OLDEST_SUPPORTED_CLI_VERSION.compare(ver) < 0) {
423+
return;
424+
}
425+
426+
void showAndLogWarningMessage(
427+
`You are using an unsupported version of the CodeQL CLI (${ver}). ` +
428+
`The minimum supported version is ${CliVersionConstraint.OLDEST_SUPPORTED_CLI_VERSION}. ` +
429+
`Please upgrade to the latest version of the CodeQL CLI.`,
430+
);
431+
unsupportedWarningShown = true;
432+
});
411433
}
412434

413435
return codeQlExtension;

0 commit comments

Comments
 (0)