From 67e683bd1bac75cd7daaf4ef85a1acdf0e76ccc1 Mon Sep 17 00:00:00 2001 From: Henry Mercer Date: Wed, 17 Dec 2025 16:02:55 +0000 Subject: [PATCH] Report bundled DB size in error if known --- lib/analyze-action.js | 6 ++++-- src/database-upload.ts | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/analyze-action.js b/lib/analyze-action.js index bea2ac913..b1e302b40 100644 --- a/lib/analyze-action.js +++ b/lib/analyze-action.js @@ -97540,9 +97540,10 @@ async function cleanupAndUploadDatabases(repositoryNwo, codeql, config, apiDetai } const reports = []; for (const language of config.languages) { + let bundledDbSize = void 0; try { const bundledDb = await bundleDb(config, language, codeql, language); - const bundledDbSize = fs13.statSync(bundledDb).size; + bundledDbSize = fs13.statSync(bundledDb).size; const bundledDbReadStream = fs13.createReadStream(bundledDb); const commitOid = await getCommitOid( getRequiredInput("checkout_path") @@ -97583,7 +97584,8 @@ async function cleanupAndUploadDatabases(repositoryNwo, codeql, config, apiDetai ); reports.push({ language, - error: getErrorMessage(e) + error: getErrorMessage(e), + ...bundledDbSize ? { zipped_upload_size_bytes: bundledDbSize } : {} }); } } diff --git a/src/database-upload.ts b/src/database-upload.ts index c3e603285..776a64e3a 100644 --- a/src/database-upload.ts +++ b/src/database-upload.ts @@ -95,13 +95,14 @@ export async function cleanupAndUploadDatabases( const reports: DatabaseUploadResult[] = []; for (const language of config.languages) { + let bundledDbSize: number | undefined = undefined; try { // Upload the database bundle. // Although we are uploading arbitrary file contents to the API, it's worth // noting that it's the API's job to validate that the contents is acceptable. // This API method is available to anyone with write access to the repo. const bundledDb = await bundleDb(config, language, codeql, language); - const bundledDbSize = fs.statSync(bundledDb).size; + bundledDbSize = fs.statSync(bundledDb).size; const bundledDbReadStream = fs.createReadStream(bundledDb); const commitOid = await gitUtils.getCommitOid( actionsUtil.getRequiredInput("checkout_path"), @@ -144,6 +145,7 @@ export async function cleanupAndUploadDatabases( reports.push({ language, error: util.getErrorMessage(e), + ...(bundledDbSize ? { zipped_upload_size_bytes: bundledDbSize } : {}), }); } }