Hi guys,

When searching through paragraphs the queue breaks because of the following error

An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /global/batch?id=239131&op=do_nojs&op=do
StatusText: OK
ResponseText: Error: Call to a member function getEntityTypeId() on null in Drupal\scanner\Plugin\Scanner\Paragraph->search() (line 56 of /var/www/html/web/web/modules/contrib/scanner/src/Plugin/Scanner/Paragraph.php).

Will try to investigate and find the cause of this issue.

Issue fork scanner-3200455

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

digitalarchitect created an issue. See original summary.

damienmckenna’s picture

Priority: Critical » Normal
Status: Needs review » Active
damienmckenna’s picture

Issue tags: +Needs tests

We'll need to include test coverage for this.

damienmckenna’s picture

Status: Active » Closed (duplicate)
Issue tags: -Needs tests
Parent issue: » #3196225: Error with text field replacement in paragraphs

There's another issue for this that has a patch/merge request, so let's close this one and work on the other one.

hemangi.gokhale’s picture

Version: 8.x-1.0-rc4 » 2.0.x-dev
Assigned: Unassigned » hemangi.gokhale
Status: Closed (duplicate) » Needs work

This issue is still reproducible. As Stephen mentioned in #3196225, I updated the module to 2.0.x version, using Drupal 10.6.2. Here is what the error trace looks like:

#0 /var/www/html/docroot/modules/contrib/scanner/src/Plugin/Scanner/Entity.php(62): Drupal\scanner\Plugin\Scanner\Paragraph->search()
#1 /var/www/html/docroot/modules/contrib/scanner/src/Form/ScannerForm.php(297): Drupal\scanner\Plugin\Scanner\Entity->search()
#2 /var/www/html/docroot/core/includes/batch.inc(296): Drupal\scanner\Form\ScannerForm::batchSearch()
#3 /var/www/html/docroot/core/includes/batch.inc(138): _batch_process()
#4 /var/www/html/docroot/core/includes/batch.inc(95): _batch_do()
#5 /var/www/html/docroot/core/modules/system/src/Controller/BatchController.php(52): _batch_page()
#6 [internal function]: Drupal\system\Controller\BatchController->batchPage()
#7 /var/www/html/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#8 /var/www/html/docroot/core/lib/Drupal/Core/Render/Renderer.php(637): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#9 /var/www/html/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext()
#10 /var/www/html/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#11 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#12 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#13 /var/www/html/docroot/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle()
#14 /var/www/html/docroot/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#15 /var/www/html/docroot/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#16 /var/www/html/docroot/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle()
#17 /var/www/html/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(116): Drupal\big_pipe\StackMiddleware\ContentLength->handle()
#18 /var/www/html/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(90): Drupal\page_cache\StackMiddleware\PageCache->pass()
#19 /var/www/html/docroot/core/modules/ban/src/BanMiddleware.php(50): Drupal\page_cache\StackMiddleware\PageCache->handle()
#20 /var/www/html/docroot/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\ban\BanMiddleware->handle()
#21 /var/www/html/docroot/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#22 /var/www/html/docroot/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#23 /var/www/html/docroot/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle()
#24 /var/www/html/docroot/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
#25 /var/www/html/docroot/index.php(19): Drupal\Core\DrupalKernel->handle()
#26 {main}

I believe we need to add null or empty checks to avoid errors when processing Scanner results. The main issues are:

1. Match count increments in ScannerForm fail when $data['field'] is empty
2. Regex processing in the Node scanner does not validate $matches[0] before accessing it
3. Paragraph scanner does not safely handle orphaned paragraphs or nested entity hierarchies

hemangi.gokhale’s picture

Issue tags: +Needs tests
StatusFileSize
new4.33 KB

Attached is the MVP patch that ensures null checks are added before processing field data, regex matches, and handling orphaned paragraphs, and that safely traverses nested entity parents. This issue now needs tests.

damienmckenna’s picture

damienmckenna’s picture

Assigned: hemangi.gokhale » Unassigned
damienmckenna’s picture

hemangi.gokhale’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
Related issues: +#3196119: Errors on search-only for deep-nested paragraphs
StatusFileSize
new9.01 KB

I've added the testcases. Thank you!

damienmckenna’s picture

Status: Needs review » Fixed

Committed. Thank you!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.