From 26f5c5e4e0aaac24bf3f31e064343e3229fbbec6 Mon Sep 17 00:00:00 2001 From: "Michael B. Gale" Date: Thu, 22 Oct 2026 10:30:34 +0100 Subject: [PATCH] Improve logging and error handling in `logTemporaryDiagnostics` --- lib/entry-points.js | 16 ++++++++++++---- src/diagnostics.ts | 17 +++++++++++++---- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/lib/entry-points.js b/lib/entry-points.js index 6128fe3b4..5fde8a09a 100644 --- a/lib/entry-points.js +++ b/lib/entry-points.js @@ -173085,13 +173085,21 @@ function writeDiagnostic(action, config, language, diagnostic) { } function logTemporaryDiagnostics(action) { const num = temporaryDiagnostics.length; - if (num > 0) { - action.logger.warning( - `${num} diagnostic(s) could not be written to the database and will not appear on the Tool Status Page.` + if (num > 0 && action.logger.isDebug()) { + action.logger.startGroup("Diagnostics in temporary location"); + action.logger.debug( + `${num} diagnostic(s) were not moved to the database and remain in the temporary directory.` ); for (const temporary of temporaryDiagnostics) { - action.logger.debug(fs7.readFileSync(temporary.path, "utf-8")); + try { + action.logger.debug(fs7.readFileSync(temporary.path, "utf-8")); + } catch (err) { + action.logger.debug( + `Failed to read diagnostics from temporary location at '${temporary.path}': ${getErrorMessage(err)}` + ); + } } + action.logger.endGroup(); } } function flushDiagnostics(action, config) { diff --git a/src/diagnostics.ts b/src/diagnostics.ts index 272706c4e..2c5fe909d 100644 --- a/src/diagnostics.ts +++ b/src/diagnostics.ts @@ -303,14 +303,23 @@ function writeDiagnostic( export function logTemporaryDiagnostics(action: ActionState<["Logger"]>) { const num = temporaryDiagnostics.length; - if (num > 0) { - action.logger.warning( - `${num} diagnostic(s) could not be written to the database and will not appear on the Tool Status Page.`, + if (num > 0 && action.logger.isDebug()) { + action.logger.startGroup("Diagnostics in temporary location"); + action.logger.debug( + `${num} diagnostic(s) were not moved to the database and remain in the temporary directory.`, ); for (const temporary of temporaryDiagnostics) { - action.logger.debug(fs.readFileSync(temporary.path, "utf-8")); + try { + action.logger.debug(fs.readFileSync(temporary.path, "utf-8")); + } catch (err) { + action.logger.debug( + `Failed to read diagnostics from temporary location at '${temporary.path}': ${getErrorMessage(err)}`, + ); + } } + + action.logger.endGroup(); } }