Merge pull request #1816 from github/henrymercer/more-user-errors

Categorize more user errors correctly in telemetry
This commit is contained in:
Henry Mercer 2023-07-31 11:56:57 +01:00 committed by GitHub
commit 6a17359b95
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 40 additions and 9 deletions

6
lib/actions-util.js generated
View file

@ -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
View file

@ -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