Tolerate NoSourceCodeSeen errors in CCR

This commit is contained in:
Michael B. Gale
2026-01-21 15:56:37 +00:00
parent 90379d9b6f
commit 796f1f4bd8
13 changed files with 180 additions and 3 deletions
+16
View File
@@ -142861,6 +142861,7 @@ var cliErrorsConfig = {
// was unintended to have CodeQL analysis run on it.
["NoSourceCodeSeen" /* NoSourceCodeSeen */]: {
exitCode: 32,
toleratedByCCR: true,
cliErrorMessageCandidates: [
new RegExp(
"CodeQL detected code written in .* but could not process any of it"
@@ -142949,6 +142950,15 @@ function getUnsupportedPlatformError(cliError) {
`The CodeQL CLI does not support the platform/architecture combination of ${process.platform}/${process.arch} (see ${"https://codeql.github.com/docs/codeql-overview/system-requirements/" /* SYSTEM_REQUIREMENTS */}). The underlying error was: ${cliError.message}`
);
}
var ToleratedConfigurationError = class extends ConfigurationError {
constructor(category, message) {
super(message);
this.category = category;
}
getCategory() {
return this.category;
}
};
function wrapCliConfigurationError(cliError) {
if (isUnsupportedPlatform()) {
return getUnsupportedPlatformError(cliError);
@@ -142962,6 +142972,12 @@ function wrapCliConfigurationError(cliError) {
if (additionalErrorMessageToAppend !== void 0) {
errorMessageBuilder = `${errorMessageBuilder} ${additionalErrorMessageToAppend}`;
}
if (cliErrorsConfig[cliConfigErrorCategory].toleratedByCCR) {
return new ToleratedConfigurationError(
cliConfigErrorCategory,
errorMessageBuilder
);
}
return new ConfigurationError(errorMessageBuilder);
}
+18 -1
View File
@@ -105443,6 +105443,7 @@ var cliErrorsConfig = {
// was unintended to have CodeQL analysis run on it.
["NoSourceCodeSeen" /* NoSourceCodeSeen */]: {
exitCode: 32,
toleratedByCCR: true,
cliErrorMessageCandidates: [
new RegExp(
"CodeQL detected code written in .* but could not process any of it"
@@ -105531,6 +105532,15 @@ function getUnsupportedPlatformError(cliError) {
`The CodeQL CLI does not support the platform/architecture combination of ${process.platform}/${process.arch} (see ${"https://codeql.github.com/docs/codeql-overview/system-requirements/" /* SYSTEM_REQUIREMENTS */}). The underlying error was: ${cliError.message}`
);
}
var ToleratedConfigurationError = class extends ConfigurationError {
constructor(category, message) {
super(message);
this.category = category;
}
getCategory() {
return this.category;
}
};
function wrapCliConfigurationError(cliError) {
if (isUnsupportedPlatform()) {
return getUnsupportedPlatformError(cliError);
@@ -105544,6 +105554,12 @@ function wrapCliConfigurationError(cliError) {
if (additionalErrorMessageToAppend !== void 0) {
errorMessageBuilder = `${errorMessageBuilder} ${additionalErrorMessageToAppend}`;
}
if (cliErrorsConfig[cliConfigErrorCategory].toleratedByCCR) {
return new ToleratedConfigurationError(
cliConfigErrorCategory,
errorMessageBuilder
);
}
return new ConfigurationError(errorMessageBuilder);
}
@@ -111530,7 +111546,8 @@ async function run(startedAt2) {
core14.exportVariable("CODEQL_ACTION_ANALYZE_DID_COMPLETE_SUCCESSFULLY" /* ANALYZE_DID_COMPLETE_SUCCESSFULLY */, "true");
} catch (unwrappedError) {
const error3 = wrapError(unwrappedError);
if (getOptionalInput("expect-error") !== "true" || hasBadExpectErrorInput()) {
const tolerateErrorForCCR = isCCR() && error3 instanceof ToleratedConfigurationError;
if (!tolerateErrorForCCR && (getOptionalInput("expect-error") !== "true" || hasBadExpectErrorInput())) {
core14.setFailed(error3.message);
}
await sendStatusReport2(
+16
View File
@@ -102023,6 +102023,7 @@ var cliErrorsConfig = {
// was unintended to have CodeQL analysis run on it.
["NoSourceCodeSeen" /* NoSourceCodeSeen */]: {
exitCode: 32,
toleratedByCCR: true,
cliErrorMessageCandidates: [
new RegExp(
"CodeQL detected code written in .* but could not process any of it"
@@ -102111,6 +102112,15 @@ function getUnsupportedPlatformError(cliError) {
`The CodeQL CLI does not support the platform/architecture combination of ${process.platform}/${process.arch} (see ${"https://codeql.github.com/docs/codeql-overview/system-requirements/" /* SYSTEM_REQUIREMENTS */}). The underlying error was: ${cliError.message}`
);
}
var ToleratedConfigurationError = class extends ConfigurationError {
constructor(category, message) {
super(message);
this.category = category;
}
getCategory() {
return this.category;
}
};
function wrapCliConfigurationError(cliError) {
if (isUnsupportedPlatform()) {
return getUnsupportedPlatformError(cliError);
@@ -102124,6 +102134,12 @@ function wrapCliConfigurationError(cliError) {
if (additionalErrorMessageToAppend !== void 0) {
errorMessageBuilder = `${errorMessageBuilder} ${additionalErrorMessageToAppend}`;
}
if (cliErrorsConfig[cliConfigErrorCategory].toleratedByCCR) {
return new ToleratedConfigurationError(
cliConfigErrorCategory,
errorMessageBuilder
);
}
return new ConfigurationError(errorMessageBuilder);
}
+16
View File
@@ -146182,6 +146182,7 @@ var cliErrorsConfig = {
// was unintended to have CodeQL analysis run on it.
["NoSourceCodeSeen" /* NoSourceCodeSeen */]: {
exitCode: 32,
toleratedByCCR: true,
cliErrorMessageCandidates: [
new RegExp(
"CodeQL detected code written in .* but could not process any of it"
@@ -146270,6 +146271,15 @@ function getUnsupportedPlatformError(cliError) {
`The CodeQL CLI does not support the platform/architecture combination of ${process.platform}/${process.arch} (see ${"https://codeql.github.com/docs/codeql-overview/system-requirements/" /* SYSTEM_REQUIREMENTS */}). The underlying error was: ${cliError.message}`
);
}
var ToleratedConfigurationError = class extends ConfigurationError {
constructor(category, message) {
super(message);
this.category = category;
}
getCategory() {
return this.category;
}
};
function wrapCliConfigurationError(cliError) {
if (isUnsupportedPlatform()) {
return getUnsupportedPlatformError(cliError);
@@ -146283,6 +146293,12 @@ function wrapCliConfigurationError(cliError) {
if (additionalErrorMessageToAppend !== void 0) {
errorMessageBuilder = `${errorMessageBuilder} ${additionalErrorMessageToAppend}`;
}
if (cliErrorsConfig[cliConfigErrorCategory].toleratedByCCR) {
return new ToleratedConfigurationError(
cliConfigErrorCategory,
errorMessageBuilder
);
}
return new ConfigurationError(errorMessageBuilder);
}
+16
View File
@@ -105276,6 +105276,7 @@ var cliErrorsConfig = {
// was unintended to have CodeQL analysis run on it.
["NoSourceCodeSeen" /* NoSourceCodeSeen */]: {
exitCode: 32,
toleratedByCCR: true,
cliErrorMessageCandidates: [
new RegExp(
"CodeQL detected code written in .* but could not process any of it"
@@ -105364,6 +105365,15 @@ function getUnsupportedPlatformError(cliError) {
`The CodeQL CLI does not support the platform/architecture combination of ${process.platform}/${process.arch} (see ${"https://codeql.github.com/docs/codeql-overview/system-requirements/" /* SYSTEM_REQUIREMENTS */}). The underlying error was: ${cliError.message}`
);
}
var ToleratedConfigurationError = class extends ConfigurationError {
constructor(category, message) {
super(message);
this.category = category;
}
getCategory() {
return this.category;
}
};
function wrapCliConfigurationError(cliError) {
if (isUnsupportedPlatform()) {
return getUnsupportedPlatformError(cliError);
@@ -105377,6 +105387,12 @@ function wrapCliConfigurationError(cliError) {
if (additionalErrorMessageToAppend !== void 0) {
errorMessageBuilder = `${errorMessageBuilder} ${additionalErrorMessageToAppend}`;
}
if (cliErrorsConfig[cliConfigErrorCategory].toleratedByCCR) {
return new ToleratedConfigurationError(
cliConfigErrorCategory,
errorMessageBuilder
);
}
return new ConfigurationError(errorMessageBuilder);
}
+16
View File
@@ -102022,6 +102022,7 @@ var cliErrorsConfig = {
// was unintended to have CodeQL analysis run on it.
["NoSourceCodeSeen" /* NoSourceCodeSeen */]: {
exitCode: 32,
toleratedByCCR: true,
cliErrorMessageCandidates: [
new RegExp(
"CodeQL detected code written in .* but could not process any of it"
@@ -102110,6 +102111,15 @@ function getUnsupportedPlatformError(cliError) {
`The CodeQL CLI does not support the platform/architecture combination of ${process.platform}/${process.arch} (see ${"https://codeql.github.com/docs/codeql-overview/system-requirements/" /* SYSTEM_REQUIREMENTS */}). The underlying error was: ${cliError.message}`
);
}
var ToleratedConfigurationError = class extends ConfigurationError {
constructor(category, message) {
super(message);
this.category = category;
}
getCategory() {
return this.category;
}
};
function wrapCliConfigurationError(cliError) {
if (isUnsupportedPlatform()) {
return getUnsupportedPlatformError(cliError);
@@ -102123,6 +102133,12 @@ function wrapCliConfigurationError(cliError) {
if (additionalErrorMessageToAppend !== void 0) {
errorMessageBuilder = `${errorMessageBuilder} ${additionalErrorMessageToAppend}`;
}
if (cliErrorsConfig[cliConfigErrorCategory].toleratedByCCR) {
return new ToleratedConfigurationError(
cliConfigErrorCategory,
errorMessageBuilder
);
}
return new ConfigurationError(errorMessageBuilder);
}
+16
View File
@@ -102946,6 +102946,7 @@ var cliErrorsConfig = {
// was unintended to have CodeQL analysis run on it.
["NoSourceCodeSeen" /* NoSourceCodeSeen */]: {
exitCode: 32,
toleratedByCCR: true,
cliErrorMessageCandidates: [
new RegExp(
"CodeQL detected code written in .* but could not process any of it"
@@ -103034,6 +103035,15 @@ function getUnsupportedPlatformError(cliError) {
`The CodeQL CLI does not support the platform/architecture combination of ${process.platform}/${process.arch} (see ${"https://codeql.github.com/docs/codeql-overview/system-requirements/" /* SYSTEM_REQUIREMENTS */}). The underlying error was: ${cliError.message}`
);
}
var ToleratedConfigurationError = class extends ConfigurationError {
constructor(category, message) {
super(message);
this.category = category;
}
getCategory() {
return this.category;
}
};
function wrapCliConfigurationError(cliError) {
if (isUnsupportedPlatform()) {
return getUnsupportedPlatformError(cliError);
@@ -103047,6 +103057,12 @@ function wrapCliConfigurationError(cliError) {
if (additionalErrorMessageToAppend !== void 0) {
errorMessageBuilder = `${errorMessageBuilder} ${additionalErrorMessageToAppend}`;
}
if (cliErrorsConfig[cliConfigErrorCategory].toleratedByCCR) {
return new ToleratedConfigurationError(
cliConfigErrorCategory,
errorMessageBuilder
);
}
return new ConfigurationError(errorMessageBuilder);
}
+1
View File
@@ -143012,6 +143012,7 @@ var cliErrorsConfig = {
// was unintended to have CodeQL analysis run on it.
["NoSourceCodeSeen" /* NoSourceCodeSeen */]: {
exitCode: 32,
toleratedByCCR: true,
cliErrorMessageCandidates: [
new RegExp(
"CodeQL detected code written in .* but could not process any of it"
+16
View File
@@ -105056,6 +105056,7 @@ var cliErrorsConfig = {
// was unintended to have CodeQL analysis run on it.
["NoSourceCodeSeen" /* NoSourceCodeSeen */]: {
exitCode: 32,
toleratedByCCR: true,
cliErrorMessageCandidates: [
new RegExp(
"CodeQL detected code written in .* but could not process any of it"
@@ -105144,6 +105145,15 @@ function getUnsupportedPlatformError(cliError) {
`The CodeQL CLI does not support the platform/architecture combination of ${process.platform}/${process.arch} (see ${"https://codeql.github.com/docs/codeql-overview/system-requirements/" /* SYSTEM_REQUIREMENTS */}). The underlying error was: ${cliError.message}`
);
}
var ToleratedConfigurationError = class extends ConfigurationError {
constructor(category, message) {
super(message);
this.category = category;
}
getCategory() {
return this.category;
}
};
function wrapCliConfigurationError(cliError) {
if (isUnsupportedPlatform()) {
return getUnsupportedPlatformError(cliError);
@@ -105157,6 +105167,12 @@ function wrapCliConfigurationError(cliError) {
if (additionalErrorMessageToAppend !== void 0) {
errorMessageBuilder = `${errorMessageBuilder} ${additionalErrorMessageToAppend}`;
}
if (cliErrorsConfig[cliConfigErrorCategory].toleratedByCCR) {
return new ToleratedConfigurationError(
cliConfigErrorCategory,
errorMessageBuilder
);
}
return new ConfigurationError(errorMessageBuilder);
}
+1
View File
@@ -142696,6 +142696,7 @@ var cliErrorsConfig = {
// was unintended to have CodeQL analysis run on it.
["NoSourceCodeSeen" /* NoSourceCodeSeen */]: {
exitCode: 32,
toleratedByCCR: true,
cliErrorMessageCandidates: [
new RegExp(
"CodeQL detected code written in .* but could not process any of it"
+16
View File
@@ -106224,6 +106224,7 @@ var cliErrorsConfig = {
// was unintended to have CodeQL analysis run on it.
["NoSourceCodeSeen" /* NoSourceCodeSeen */]: {
exitCode: 32,
toleratedByCCR: true,
cliErrorMessageCandidates: [
new RegExp(
"CodeQL detected code written in .* but could not process any of it"
@@ -106312,6 +106313,15 @@ function getUnsupportedPlatformError(cliError) {
`The CodeQL CLI does not support the platform/architecture combination of ${process.platform}/${process.arch} (see ${"https://codeql.github.com/docs/codeql-overview/system-requirements/" /* SYSTEM_REQUIREMENTS */}). The underlying error was: ${cliError.message}`
);
}
var ToleratedConfigurationError = class extends ConfigurationError {
constructor(category, message) {
super(message);
this.category = category;
}
getCategory() {
return this.category;
}
};
function wrapCliConfigurationError(cliError) {
if (isUnsupportedPlatform()) {
return getUnsupportedPlatformError(cliError);
@@ -106325,6 +106335,12 @@ function wrapCliConfigurationError(cliError) {
if (additionalErrorMessageToAppend !== void 0) {
errorMessageBuilder = `${errorMessageBuilder} ${additionalErrorMessageToAppend}`;
}
if (cliErrorsConfig[cliConfigErrorCategory].toleratedByCCR) {
return new ToleratedConfigurationError(
cliConfigErrorCategory,
errorMessageBuilder
);
}
return new ConfigurationError(errorMessageBuilder);
}
+10 -2
View File
@@ -18,6 +18,7 @@ import {
import { getApiDetails, getGitHubVersion } from "./api-client";
import { runAutobuild } from "./autobuild";
import { getTotalCacheSize, shouldStoreCache } from "./caching-utils";
import { ToleratedConfigurationError } from "./cli-errors";
import { getCodeQL } from "./codeql";
import { Config, getConfig } from "./config-utils";
import {
@@ -450,9 +451,16 @@ async function run(startedAt: Date) {
core.exportVariable(EnvVar.ANALYZE_DID_COMPLETE_SUCCESSFULLY, "true");
} catch (unwrappedError) {
const error = util.wrapError(unwrappedError);
const tolerateErrorForCCR =
actionsUtil.isCCR() && error instanceof ToleratedConfigurationError;
// Set the outcome of the action as failed if we are not expecting an error,
// or the `expect-error` value is invalid.
if (
actionsUtil.getOptionalInput("expect-error") !== "true" ||
hasBadExpectErrorInput()
!tolerateErrorForCCR &&
(actionsUtil.getOptionalInput("expect-error") !== "true" ||
hasBadExpectErrorInput())
) {
core.setFailed(error.message);
}
+22
View File
@@ -153,6 +153,7 @@ type CliErrorConfiguration = {
cliErrorMessageCandidates: RegExp[];
exitCode?: number;
additionalErrorMessageToAppend?: string;
toleratedByCCR?: boolean;
};
/**
@@ -228,6 +229,7 @@ const cliErrorsConfig: Record<CliConfigErrorCategory, CliErrorConfiguration> = {
// was unintended to have CodeQL analysis run on it.
[CliConfigErrorCategory.NoSourceCodeSeen]: {
exitCode: 32,
toleratedByCCR: true,
cliErrorMessageCandidates: [
new RegExp(
"CodeQL detected code written in .* but could not process any of it",
@@ -345,6 +347,20 @@ function getUnsupportedPlatformError(cliError: CliError): ConfigurationError {
);
}
export class ToleratedConfigurationError extends ConfigurationError {
private category: CliConfigErrorCategory;
constructor(category: CliConfigErrorCategory, message: string) {
super(message);
this.category = category;
}
public getCategory(): CliConfigErrorCategory {
return this.category;
}
}
/**
* Changes an error received from the CLI to a ConfigurationError with the message
* optionally being transformed, if it is a known configuration error. Otherwise,
@@ -368,5 +384,11 @@ export function wrapCliConfigurationError(cliError: CliError): Error {
errorMessageBuilder = `${errorMessageBuilder} ${additionalErrorMessageToAppend}`;
}
if (cliErrorsConfig[cliConfigErrorCategory].toleratedByCCR) {
return new ToleratedConfigurationError(
cliConfigErrorCategory,
errorMessageBuilder,
);
}
return new ConfigurationError(errorMessageBuilder);
}