Skip to content

Add error summary at end of update all command#251

Open
michieldegezelle wants to merge 6 commits intomainfrom
139-add-error-summary-at-end-of-update-all-command
Open

Add error summary at end of update all command#251
michieldegezelle wants to merge 6 commits intomainfrom
139-add-error-summary-at-end-of-update-all-command

Conversation

@michieldegezelle
Copy link
Copy Markdown
Contributor

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:

  1. Run the silverfin update-reconciliation --all command
  2. Run the silverfin update-export-file --all command
  3. Run the silverfin update-account-template --all command
  4. Run the silverfin update-shared-part --all command

Author Checklist

  • Skip bumping the CLI version

Reviewer Checklist

  • PR has a clear title and description
  • Manually tested the changes that the PR introduces
  • Changes introduced are covered by tests of acceptable quality

@michieldegezelle michieldegezelle self-assigned this Mar 24, 2026
@michieldegezelle
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 24, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 24, 2026

Walkthrough

Extends silverfin-cli publish functions with optional error deferral and batch summarization capabilities. Adds architecture and contributor guidance documentation, new error summary utilities, and comprehensive test coverage for batch update workflows. Includes configuration additions for Cursor and .gitignore.

Changes

Cohort / File(s) Summary
Documentation & Guidance
AGENTS.md, docs/ARCHITECTURE.md, .cursor/rules/silverfin-cli-context.mdc
New repository orientation guide, architecture documentation, and Cursor AI context rule defining module entry points, public API stability expectations, coding style deference, and development workflow.
Core Publishing Logic
index.js
Extended publish*ByHandle and publish*ByName functions (reconciliationText, exportFile, accountTemplate, sharedPart) with optional deferredErrors parameter to collect failures instead of immediate error handling. Updated publishAll* batch functions to aggregate errors and call new batch error summary utilities.
Error Handling Utilities
lib/utils/errorUtils.js
Added four new batch error summary functions (printReconciliationBatchErrorSummary, printExportFileBatchErrorSummary, printSharedPartBatchErrorSummary, printAccountTemplateBatchErrorSummary) to format and display collected errors with type-specific messages and recovery hints.
Tests & Configuration
tests/lib/batchUpdateSummaries.test.js, .gitignore
New comprehensive test suite validating error deferral behavior, batch summarization, exit code handling, and individual publish function contracts. Added ignore pattern for temporary test directories.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 19.05% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding error summaries at the end of batch update commands.
Description check ✅ Passed The description follows the template structure with all required sections populated: issue link placeholder, clear description of changes, testing instructions for all affected commands, and both checklists included.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 139-add-error-summary-at-end-of-update-all-command

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
lib/utils/errorUtils.js (1)

56-87: Consider extracting a generic batch error summary helper to reduce duplication.

All four print*BatchErrorSummary functions 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

📥 Commits

Reviewing files that changed from the base of the PR and between 840b02d and d550c3c.

📒 Files selected for processing (7)
  • .cursor/rules/silverfin-cli-context.mdc
  • .gitignore
  • AGENTS.md
  • docs/ARCHITECTURE.md
  • index.js
  • lib/utils/errorUtils.js
  • tests/lib/batchUpdateSummaries.test.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant