From 796f1f4bd888dda990877c9b3255a80990a889f7 Mon Sep 17 00:00:00 2001 From: "Michael B. Gale" Date: Wed, 21 Jan 2026 15:56:37 +0000 Subject: [PATCH] Tolerate `NoSourceCodeSeen` errors in CCR --- lib/analyze-action-post.js | 16 ++++++++++++++++ lib/analyze-action.js | 19 ++++++++++++++++++- lib/autobuild-action.js | 16 ++++++++++++++++ lib/init-action-post.js | 16 ++++++++++++++++ lib/init-action.js | 16 ++++++++++++++++ lib/resolve-environment-action.js | 16 ++++++++++++++++ lib/setup-codeql-action.js | 16 ++++++++++++++++ lib/start-proxy-action-post.js | 1 + lib/upload-lib.js | 16 ++++++++++++++++ lib/upload-sarif-action-post.js | 1 + lib/upload-sarif-action.js | 16 ++++++++++++++++ src/analyze-action.ts | 12 ++++++++++-- src/cli-errors.ts | 22 ++++++++++++++++++++++ 13 files changed, 180 insertions(+), 3 deletions(-) diff --git a/lib/analyze-action-post.js b/lib/analyze-action-post.js index 3e7718996..509fd405b 100644 --- a/lib/analyze-action-post.js +++ b/lib/analyze-action-post.js @@ -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); } diff --git a/lib/analyze-action.js b/lib/analyze-action.js index 10b796278..0ea697d64 100644 --- a/lib/analyze-action.js +++ b/lib/analyze-action.js @@ -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( diff --git a/lib/autobuild-action.js b/lib/autobuild-action.js index 41707279b..66f6c7eac 100644 --- a/lib/autobuild-action.js +++ b/lib/autobuild-action.js @@ -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); } diff --git a/lib/init-action-post.js b/lib/init-action-post.js index 9aa6dbf87..f5bcb6b47 100644 --- a/lib/init-action-post.js +++ b/lib/init-action-post.js @@ -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); } diff --git a/lib/init-action.js b/lib/init-action.js index a90cc5565..fc2a5a187 100644 --- a/lib/init-action.js +++ b/lib/init-action.js @@ -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); } diff --git a/lib/resolve-environment-action.js b/lib/resolve-environment-action.js index 5093055f9..cc6a384e5 100644 --- a/lib/resolve-environment-action.js +++ b/lib/resolve-environment-action.js @@ -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); } diff --git a/lib/setup-codeql-action.js b/lib/setup-codeql-action.js index 59af2bf5c..5828f88d0 100644 --- a/lib/setup-codeql-action.js +++ b/lib/setup-codeql-action.js @@ -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); } diff --git a/lib/start-proxy-action-post.js b/lib/start-proxy-action-post.js index 331b4d250..532dcfd78 100644 --- a/lib/start-proxy-action-post.js +++ b/lib/start-proxy-action-post.js @@ -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" diff --git a/lib/upload-lib.js b/lib/upload-lib.js index 4917e2df6..56837203a 100644 --- a/lib/upload-lib.js +++ b/lib/upload-lib.js @@ -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); } diff --git a/lib/upload-sarif-action-post.js b/lib/upload-sarif-action-post.js index 9eb735667..5db204b90 100644 --- a/lib/upload-sarif-action-post.js +++ b/lib/upload-sarif-action-post.js @@ -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" diff --git a/lib/upload-sarif-action.js b/lib/upload-sarif-action.js index 852442e17..d31a0fa91 100644 --- a/lib/upload-sarif-action.js +++ b/lib/upload-sarif-action.js @@ -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); } diff --git a/src/analyze-action.ts b/src/analyze-action.ts index 3cc1ad019..3d544afad 100644 --- a/src/analyze-action.ts +++ b/src/analyze-action.ts @@ -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); } diff --git a/src/cli-errors.ts b/src/cli-errors.ts index 5aba268ca..35ddfadc5 100644 --- a/src/cli-errors.ts +++ b/src/cli-errors.ts @@ -153,6 +153,7 @@ type CliErrorConfiguration = { cliErrorMessageCandidates: RegExp[]; exitCode?: number; additionalErrorMessageToAppend?: string; + toleratedByCCR?: boolean; }; /** @@ -228,6 +229,7 @@ const cliErrorsConfig: Record = { // 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); }