Skip to content

Conversation

@adam-vessey
Copy link
Contributor

@adam-vessey adam-vessey commented Jan 5, 2026

Continuing would attempt to reference properties that are only set during the initialization (such as $context['sandbox']['total']).

Summary by CodeRabbit

  • Bug Fixes
    • Improved error handling for batch operations. When batch preparation encounters issues, the system now emits detailed warning messages with migration and exception information, while better preserving partial results.

✏️ Tip: You can customize this high-level summary in your review settings.

…atch.

Continuing would attempt to reference properties that are only set during
the initialization.
@adam-vessey adam-vessey added the patch Backwards compatible bug fixes. label Jan 5, 2026
@coderabbitai
Copy link

coderabbitai bot commented Jan 5, 2026

📝 Walkthrough

Walkthrough

The exception handler in runBatchOp now passes accumulated batch context results to finishBatch instead of empty results when prepareBatch fails, and logs a warning message with the migration ID and exception details before returning early.

Changes

Cohort / File(s) Summary
Exception Handling in Batch Operation
src/Form/Ingest/Review.php
Modified the exception path during batch preparation to preserve context results when finishing the batch, emit a warning message via messenger with migration ID and exception message, and return early instead of proceeding with empty results.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 When batches stumble and errors appear,
We now preserve the context so dear,
A warning hops forth with grace and with care,
Results are not lost, they're passed with a prayer! 🌱

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: exiting when an exception occurs during batch item enqueueing, which matches the exception handling improvement in the code.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • JIRA integration encountered authorization issues. Please disconnect and reconnect the integration in the CodeRabbit UI.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link

@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.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/Form/Ingest/Review.php (1)

163-170: Early return is essential and correct; consider consistency improvements.

The early return on line 169 is critical and correctly prevents attempting to call processBatch() on a failed/uninitialized executable. The logic is sound.

However, for consistency with other exception handlers in this class (lines 263-269, 302-308, 339-345), consider:

  1. Logging the exception - Other catch blocks log errors via $this->logger() which aids debugging
  2. Using addError() instead of addWarning() - A failed batch preparation is an error condition, not just a warning
  3. Adding the exception to $context['results']['errors'] - Based on the relevant code snippet from MigrationRollbackBatch::finishBatch(), it checks for and reports errors from the $results['errors'] array
🔎 Proposed refactor for consistency
     catch (\Exception $ex) {
+      $context['results']['errors'][] = $ex;
       $e->finishBatch(FALSE, $context['results'], [], NULL);
-      $this->messenger()->addWarning($this->t('Migration (@migration) failed to start with exception: @exception_message', [
+      $this->logger('isi.review')->error("Migration failed to start: {exc}\n{backtrace}", [
+        'exc' => $ex->getMessage(),
+        'backtrace' => $ex->getTraceAsString(),
+      ]);
+      $this->messenger()->addError($this->t('Migration (@migration) failed to start with exception: @exception_message', [
         '@migration' => $migration->id(),
         '@exception_message' => $ex->getMessage(),
       ]));
       return;
     }
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 510e7fd and a6de56e.

📒 Files selected for processing (1)
  • src/Form/Ingest/Review.php
🧰 Additional context used
🧬 Code graph analysis (1)
src/Form/Ingest/Review.php (1)
src/Util/MigrationRollbackBatch.php (1)
  • finishBatch (282-293)

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

Labels

patch Backwards compatible bug fixes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants