Merge pull request #1816 from github/henrymercer/more-user-errors
Categorize more user errors correctly in telemetry
This commit is contained in:
commit
6a17359b95
6 changed files with 40 additions and 9 deletions
6
lib/actions-util.js
generated
6
lib/actions-util.js
generated
|
|
@ -39,7 +39,11 @@ const pkg = require("../package.json");
|
|||
* This allows us to get stronger type checking of required/optional inputs.
|
||||
*/
|
||||
const getRequiredInput = function (name) {
|
||||
return core.getInput(name, { required: true });
|
||||
const value = core.getInput(name);
|
||||
if (!value) {
|
||||
throw new util_1.UserError(`Input required and not supplied: ${name}`);
|
||||
}
|
||||
return value;
|
||||
};
|
||||
exports.getRequiredInput = getRequiredInput;
|
||||
/**
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
13
lib/upload-lib.js
generated
13
lib/upload-lib.js
generated
|
|
@ -331,7 +331,10 @@ async function waitForProcessing(repositoryNwo, sarifID, logger, options = {
|
|||
break;
|
||||
}
|
||||
else if (status === "failed") {
|
||||
throw new Error(`Code Scanning could not process the submitted SARIF file:\n${response.data.errors}`);
|
||||
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)
|
||||
: new Error(message);
|
||||
}
|
||||
else {
|
||||
util.assertNever(status);
|
||||
|
|
@ -346,6 +349,14 @@ async function waitForProcessing(repositoryNwo, sarifID, logger, options = {
|
|||
}
|
||||
}
|
||||
exports.waitForProcessing = waitForProcessing;
|
||||
/**
|
||||
* Returns whether the provided processing errors should be considered a user error.
|
||||
*/
|
||||
function shouldConsiderAsUserError(processingErrors) {
|
||||
return (processingErrors.length === 1 &&
|
||||
processingErrors[0] ===
|
||||
"CodeQL analyses from advanced configurations cannot be processed when the default setup is enabled");
|
||||
}
|
||||
/**
|
||||
* Checks the processing result for an unsuccessful execution. Throws if the
|
||||
* result is not a failure with a single "unsuccessful execution" error.
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -24,7 +24,11 @@ const pkg = require("../package.json") as JSONSchemaForNPMPackageJsonFiles;
|
|||
* This allows us to get stronger type checking of required/optional inputs.
|
||||
*/
|
||||
export const getRequiredInput = function (name: string): string {
|
||||
return core.getInput(name, { required: true });
|
||||
const value = core.getInput(name);
|
||||
if (!value) {
|
||||
throw new UserError(`Input required and not supplied: ${name}`);
|
||||
}
|
||||
return value;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import * as fingerprints from "./fingerprints";
|
|||
import { Logger } from "./logging";
|
||||
import { parseRepositoryNwo, RepositoryNwo } from "./repository";
|
||||
import * as util from "./util";
|
||||
import { SarifFile, SarifResult, SarifRun, wrapError } from "./util";
|
||||
import { SarifFile, SarifResult, SarifRun, UserError, wrapError } from "./util";
|
||||
|
||||
// Takes a list of paths to sarif files and combines them together,
|
||||
// returning the contents of the combined sarif file.
|
||||
|
|
@ -472,9 +472,10 @@ export async function waitForProcessing(
|
|||
} else if (status === "complete") {
|
||||
break;
|
||||
} else if (status === "failed") {
|
||||
throw new Error(
|
||||
`Code Scanning could not process the submitted SARIF file:\n${response.data.errors}`,
|
||||
);
|
||||
const message = `Code Scanning could not process the submitted SARIF file:\n${response.data.errors}`;
|
||||
throw shouldConsiderAsUserError(response.data.errors as string[])
|
||||
? new UserError(message)
|
||||
: new Error(message);
|
||||
} else {
|
||||
util.assertNever(status);
|
||||
}
|
||||
|
|
@ -488,6 +489,17 @@ export async function waitForProcessing(
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the provided processing errors should be considered a user error.
|
||||
*/
|
||||
function shouldConsiderAsUserError(processingErrors: string[]): boolean {
|
||||
return (
|
||||
processingErrors.length === 1 &&
|
||||
processingErrors[0] ===
|
||||
"CodeQL analyses from advanced configurations cannot be processed when the default setup is enabled"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the processing result for an unsuccessful execution. Throws if the
|
||||
* result is not a failure with a single "unsuccessful execution" error.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue