Add error summary at end of update all command#251
Add error summary at end of update all command#251michieldegezelle wants to merge 6 commits intomainfrom
Conversation
…ate-all reconciliations
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
WalkthroughExtends Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
lib/utils/errorUtils.js (1)
56-87: Consider extracting a generic batch error summary helper to reduce duplication.All four
print*BatchErrorSummaryfunctions follow an identical pattern, differing only in entity name strings and hint commands. This could be consolidated into a single generic helper.♻️ Optional refactor to reduce duplication
/** * Generic batch error summary printer. * `@param` {string} entityType - e.g., "Reconciliation", "Export file" * `@param` {string} idFlag - e.g., "handle", "name" * `@param` {string} hintCommand - e.g., "silverfin get-reconciliation-id --all" * `@param` {string} hintSingle - e.g., "silverfin get-reconciliation-id --handle <handle>" * `@param` {Array} errors */ function printBatchErrorSummary(entityType, idFlag, hintCommand, hintSingle, errors) { if (!errors || errors.length === 0) return; consola.log(""); consola.error(`${entityType} update finished with ${errors.length} error(s):`); const hadMissingId = errors.some((e) => e.kind === "missing_id"); for (const e of errors) { const identifier = e.handle || e.name; if (e.kind === "missing_id") { consola.error(`${entityType} ${identifier}: ID is missing. ...`); } else if (e.kind === "update_failed") { consola.error(`${entityType} update failed: ${identifier}`); } else if (e.kind === "exception") { consola.error(identifier ? `${entityType} ${identifier}: ${e.message}` : e.message); } } if (hadMissingId) { consola.log(`Try running: ${chalk.bold(hintCommand)} (or ${chalk.bold(hintSingle)} for one template)`); } }Then each specific function becomes a thin wrapper calling the generic helper.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/utils/errorUtils.js` around lines 56 - 87, The printReconciliationBatchErrorSummary function (and the other print*BatchErrorSummary functions) duplicate the same logic; extract a generic helper like printBatchErrorSummary(entityType, idFlag, hintCommand, hintSingle, errors) that implements the shared flow (checking empty, logging header, iterating errors, detecting missing_id, and printing the hint), then refactor printReconciliationBatchErrorSummary to call this helper with entityType="Reconciliation", idFlag="handle" (or use identifier resolution based on idFlag), hintCommand="silverfin get-reconciliation-id --all" and hintSingle="silverfin get-reconciliation-id --handle <handle>" so each specific function becomes a thin wrapper that forwards its strings and errors to printBatchErrorSummary.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@lib/utils/errorUtils.js`:
- Around line 56-87: The printReconciliationBatchErrorSummary function (and the
other print*BatchErrorSummary functions) duplicate the same logic; extract a
generic helper like printBatchErrorSummary(entityType, idFlag, hintCommand,
hintSingle, errors) that implements the shared flow (checking empty, logging
header, iterating errors, detecting missing_id, and printing the hint), then
refactor printReconciliationBatchErrorSummary to call this helper with
entityType="Reconciliation", idFlag="handle" (or use identifier resolution based
on idFlag), hintCommand="silverfin get-reconciliation-id --all" and
hintSingle="silverfin get-reconciliation-id --handle <handle>" so each specific
function becomes a thin wrapper that forwards its strings and errors to
printBatchErrorSummary.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 20057c28-7cda-438b-87f3-b5f804b0873c
📒 Files selected for processing (7)
.cursor/rules/silverfin-cli-context.mdc.gitignoreAGENTS.mddocs/ARCHITECTURE.mdindex.jslib/utils/errorUtils.jstests/lib/batchUpdateSummaries.test.js
Fixes # (link to the corresponding issue if applicable)
Description
Update-all commands will now bundle all the errors and display them at the end instead of in the middle of the update process.
Testing Instructions
Steps:
silverfin update-reconciliation --allcommandsilverfin update-export-file --allcommandsilverfin update-account-template --allcommandsilverfin update-shared-part --allcommandAuthor Checklist
Reviewer Checklist