Skip to content

Merge main into releases/v2 #1942

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
8295705
Reduce duplication in the logs when errors occur in CLI commands
henrymercer Oct 6, 2023
102a12b
Add changelog note
henrymercer Oct 6, 2023
788783a
Update changelog and version after v2.22.1
github-actions[bot] Oct 9, 2023
947b43a
Update checked-in dependencies
github-actions[bot] Oct 9, 2023
d52a751
Only run `ref` and `sha` input checks against a single CLI version
henrymercer Oct 9, 2023
2125352
Merge pull request #1934 from github/mergeback/v2.22.1-to-main-fdcae64e
henrymercer Oct 9, 2023
83d1db3
Merge branch 'main' into henrymercer/reduce-log-duplication
henrymercer Oct 9, 2023
4ab9237
Merge pull request #1927 from github/henrymercer/reduce-log-duplication
henrymercer Oct 9, 2023
5d6442e
Bump the npm group with 5 updates
dependabot[bot] Oct 9, 2023
026e833
Update checked-in dependencies
github-actions[bot] Oct 9, 2023
dfb913f
Merge pull request #1936 from github/dependabot/npm_and_yarn/npm-0754…
henrymercer Oct 10, 2023
78bfd29
Merge pull request #1935 from github/henrymercer/ref-sha-input-reduce…
henrymercer Oct 10, 2023
2a7218b
Bump CLI version for new analysis summaries to v2.15.0
henrymercer Oct 10, 2023
d5d445b
Update default bundle to codeql-bundle-v2.15.0
github-actions[bot] Oct 10, 2023
275f994
Add changelog note
github-actions[bot] Oct 10, 2023
0eb2790
Merge branch 'main' into update-bundle/codeql-bundle-v2.15.0
henrymercer Oct 10, 2023
a67b110
Merge pull request #1937 from github/henrymercer/new-analysis-summary…
henrymercer Oct 10, 2023
a5cf70c
Merge branch 'main' into update-bundle/codeql-bundle-v2.15.0
henrymercer Oct 11, 2023
8a2cbab
Merge pull request #1938 from github/update-bundle/codeql-bundle-v2.15.0
henrymercer Oct 11, 2023
175f696
Update changelog for v2.22.2
github-actions[bot] Oct 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Reduce duplication in the logs when errors occur in CLI commands
  • Loading branch information
henrymercer committed Oct 6, 2023
commit 82957056408f881d9b75b07ec2fd757fdd60834f
6 changes: 1 addition & 5 deletions lib/analyze.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/analyze.js.map

Large diffs are not rendered by default.

21 changes: 15 additions & 6 deletions lib/codeql.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/codeql.js.map

Large diffs are not rendered by default.

16 changes: 14 additions & 2 deletions lib/codeql.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/codeql.test.js.map

Large diffs are not rendered by default.

6 changes: 1 addition & 5 deletions src/analyze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,14 +394,10 @@ export async function runQueries(
await runPrintLinesOfCode(language);
}
} catch (e) {
logger.info(String(e));
if (e instanceof Error) {
logger.info(e.stack!);
}
statusReport.analyze_failure_language = language;
throw new CodeQLAnalysisError(
statusReport,
`Error running analysis for ${language}: ${e}`,
`Error running analysis for ${language}: ${util.wrapError(e).message}`,
);
}
}
Expand Down
23 changes: 21 additions & 2 deletions src/codeql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,7 @@ test("database finalize does not override no code found error on CodeQL 2.12.4",
{
message:
'Encountered a fatal error while running "codeql-for-testing database finalize --finalize-dataset --threads=2 --ram=2048 db". ' +
`Exit code was 32 and error was: ${cliMessage}`,
`Exit code was 32 and last log line was: ${cliMessage} See the logs for more details.`,
},
);
});
Expand All @@ -1158,7 +1158,26 @@ test("runTool summarizes several fatal errors", async (t) => {
{
message:
'Encountered a fatal error while running "codeql-for-testing database finalize --finalize-dataset --threads=2 --ram=2048 db". ' +
`Exit code was 32 and error was: ${datasetImportError}. Context: ${heapError}.`,
`Exit code was 32 and error was: ${datasetImportError}. Context: ${heapError}. See the logs for more details.`,
},
);
});

test("runTool outputs last line of stderr if fatal error could not be found", async (t) => {
const cliStderr = "line1\nline2\nline3\nline4\nline5";
stubToolRunnerConstructor(32, cliStderr);
const codeqlObject = await codeql.getCodeQLForTesting();
sinon.stub(codeqlObject, "getVersion").resolves(makeVersionInfo("2.12.4"));
// safeWhich throws because of the test CodeQL object.
sinon.stub(safeWhich, "safeWhich").resolves("");

await t.throwsAsync(
async () =>
await codeqlObject.finalizeDatabase("db", "--threads=2", "--ram=2048"),
{
message:
'Encountered a fatal error while running "codeql-for-testing database finalize --finalize-dataset --threads=2 --ram=2048 db". ' +
"Exit code was 32 and last log line was: line5. See the logs for more details.",
},
);
});
Expand Down
21 changes: 16 additions & 5 deletions src/codeql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,27 @@ export class CommandInvocationError extends Error {
cmd: string,
args: string[],
public exitCode: number,
public error: string,
public output: string,
public stderr: string,
public stdout: string,
) {
const prettyCommand = [cmd, ...args]
.map((x) => (x.includes(" ") ? `'${x}'` : x))
.join(" ");

const fatalErrors = extractFatalErrors(stderr);
const lastLine = stderr.trim().split("\n").pop()?.trim();
let error = fatalErrors
? ` and error was: ${fatalErrors.trim()}`
: lastLine
? ` and last log line was: ${lastLine}`
: "";
if (error[error.length - 1] !== ".") {
error += ".";
}

super(
`Encountered a fatal error while running "${prettyCommand}". ` +
`Exit code was ${exitCode} and error was: ${error.trim()}`,
`Exit code was ${exitCode}${error} See the logs for more details.`,
);
}
}
Expand Down Expand Up @@ -1238,7 +1250,6 @@ async function runTool(
...(opts.stdin ? { input: Buffer.from(opts.stdin || "") } : {}),
}).exec();
if (exitCode !== 0) {
error = extractFatalErrors(error) || error;
throw new CommandInvocationError(cmd, args, exitCode, error, output);
}
return output;
Expand Down Expand Up @@ -1454,7 +1465,7 @@ function isNoCodeFoundError(e: CommandInvocationError): boolean {
*/
const javascriptNoCodeFoundWarning =
"No JavaScript or TypeScript code found.";
return e.exitCode === 32 || e.error.includes(javascriptNoCodeFoundWarning);
return e.exitCode === 32 || e.stderr.includes(javascriptNoCodeFoundWarning);
}

async function isDiagnosticsExportInvalidSarifFixed(
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy