mirror of
https://github.com/github/codeql-action.git
synced 2025-12-24 08:10:06 +08:00
Refactor configuration errors (#2105)
Refactor the existing classes of configuration errors into their own file; consolidate the place we check for configuration errors into `codeql.ts`, where the actual command invocations happen. Also, rename the `UserError` type to `ConfigurationError` to standardize on a single term.
This commit is contained in:
14
lib/upload-lib.js
generated
14
lib/upload-lib.js
generated
@@ -132,17 +132,17 @@ exports.findSarifFilesInDir = findSarifFilesInDir;
|
||||
* Uploads a single SARIF file or a directory of SARIF files depending on what `sarifPath` refers
|
||||
* to.
|
||||
*
|
||||
* @param considerInvalidRequestUserError Whether an invalid request, for example one with a
|
||||
* @param considerInvalidRequestConfigError Whether an invalid request, for example one with a
|
||||
* `sarifPath` that does not exist, should be considered a
|
||||
* user error.
|
||||
*/
|
||||
async function uploadFromActions(sarifPath, checkoutPath, category, logger, { considerInvalidRequestUserError, }) {
|
||||
async function uploadFromActions(sarifPath, checkoutPath, category, logger, { considerInvalidRequestConfigError: considerInvalidRequestConfigError, }) {
|
||||
try {
|
||||
return await uploadFiles(getSarifFilePaths(sarifPath), (0, repository_1.parseRepositoryNwo)(util.getRequiredEnvParam("GITHUB_REPOSITORY")), await actionsUtil.getCommitOid(checkoutPath), await actionsUtil.getRef(), await api.getAnalysisKey(), category, util.getRequiredEnvParam("GITHUB_WORKFLOW"), actionsUtil.getWorkflowRunID(), actionsUtil.getWorkflowRunAttempt(), checkoutPath, actionsUtil.getRequiredInput("matrix"), logger);
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof InvalidRequestError && considerInvalidRequestUserError) {
|
||||
throw new util_1.UserError(e.message);
|
||||
if (e instanceof InvalidRequestError && considerInvalidRequestConfigError) {
|
||||
throw new util_1.ConfigurationError(e.message);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
@@ -343,8 +343,8 @@ async function waitForProcessing(repositoryNwo, sarifID, logger, options = {
|
||||
}
|
||||
else if (status === "failed") {
|
||||
const message = `Code Scanning could not process the submitted SARIF file:\n${response.data.errors}`;
|
||||
throw shouldConsiderAsUserError(response.data.errors)
|
||||
? new util_1.UserError(message)
|
||||
throw shouldConsiderConfigurationError(response.data.errors)
|
||||
? new util_1.ConfigurationError(message)
|
||||
: new InvalidRequestError(message);
|
||||
}
|
||||
else {
|
||||
@@ -363,7 +363,7 @@ exports.waitForProcessing = waitForProcessing;
|
||||
/**
|
||||
* Returns whether the provided processing errors should be considered a user error.
|
||||
*/
|
||||
function shouldConsiderAsUserError(processingErrors) {
|
||||
function shouldConsiderConfigurationError(processingErrors) {
|
||||
return (processingErrors.length === 1 &&
|
||||
processingErrors[0] ===
|
||||
"CodeQL analyses from advanced configurations cannot be processed when the default setup is enabled");
|
||||
|
||||
Reference in New Issue
Block a user