I'm getting an error when trying to extract some data with extract images disabled

Created on 29 August 2024, 3 months ago
Updated 30 August 2024, 3 months ago

Problem/Motivation

Warning: Undefined array key "image_mime_type" in /app/web/modules/contrib/unstructured/src/Formatters/MarkdownFormatter.php on line 188
Warning: Undefined array key "image_base64" in /app/web/modules/contrib/unstructured/src/Formatters/MarkdownFormatter.php on line 202
Deprecated: base64_decode(): Passing null to parameter #1 ($string) of type string is deprecated in /app/web/modules/contrib/unstructured/src/Formatters/MarkdownFormatter.php on line 202
The website encountered an unexpected error. Try again later.TypeError: Drupal\unstructured\Formatters\MarkdownFormatter::formatType(): Return value must be of type string, none returned in Drupal\unstructured\Formatters\MarkdownFormatter->formatType() (line 93 of modules/contrib/unstructured/src/Formatters/MarkdownFormatter.php). Drupal\unstructured\Formatters\MarkdownFormatter->format(Array, 'none') (Line: 246)
Drupal\unstructured\Plugin\AiAutomatorType\FileToTextBase->generate(Object, Object, Array) (Line: 70)
Drupal\ai_automator\AiAutomatorRuleRunner->generateResponse(Object, Object, Array) (Line: 70)
Drupal\ai_automator\Plugin\AiAutomatorProcess\DirectSaveProcessing->modify(Object, Object, Array) (Line: 229)
Drupal\ai_automator\AiAutomatorEntityModifier->markFieldForProcessing(Object, Object, Array, Object) (Line: 129)
Drupal\ai_automator\AiAutomatorEntityModifier->saveEntity(Object) (Line: 31)
ai_automator_entity_presave(Object)
call_user_func_array(Object, Array) (Line: 416)
Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}(Object, 'ai_automator') (Line: 395)
Drupal\Core\Extension\ModuleHandler->invokeAllWith('entity_presave', Object) (Line: 415)
Drupal\Core\Extension\ModuleHandler->invokeAll('entity_presave', Array) (Line: 217)
Drupal\Core\Entity\EntityStorageBase->invokeHook('presave', Object) (Line: 900)
Drupal\Core\Entity\ContentEntityStorageBase->invokeHook('presave', Object) (Line: 529)
Drupal\Core\Entity\EntityStorageBase->doPreSave(Object) (Line: 753)
Drupal\Core\Entity\ContentEntityStorageBase->doPreSave(Object) (Line: 483)
Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 806)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 354)
Drupal\Core\Entity\EntityBase->save() (Line: 107)
Drupal\custom\Batch\MinutesParserBatch->create(0, '121300', '232770', Array) (Line: 76)
Drupal\custom\Batch\MinutesParserBatch::process(0, Array, '232770', Array) (Line: 296)
_batch_process() (Line: 138)
_batch_do() (Line: 94)
_batch_page(Object) (Line: 52)
Drupal\system\Controller\BatchController->batchPage(Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 53)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 38)
Drupal\mercury_editor\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 741)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Steps to reproduce

Proposed resolution

Remaining tasks

Outline solution

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States nicxvan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @nicxvan
  • Merge request !3Add fallback β†’ (Open) created by nicxvan
  • Status changed to Needs review 3 months ago
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan
  • πŸ‡©πŸ‡ͺGermany marcus_johansson

    So there are two bugs happening here actually:

    1. If you disabled the generate images, the markdown system should be aware of that and not generate images. I seem to have forgot that totally, I created a separate ticket for it here and will have a look during the weekend: https://www.drupal.org/project/unstructured/issues/3471136 πŸ› Disabling generate Images on Markdown (and possibly everywhere) is ignored Active
    2. The other thing your code solves, seems to be an image existing without metadata? I think your solution is as close as we get - it returns empty, because it can't generate the image.

    If you want me to have a look at it, I would need to have a test document, if its not a secret, but I don't think I can improve on the solution tbh. So I would be happy to merge this as a solution, when the image is missing metadata. Let me know.

  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    I think there is a third one, an unrecognized response being sent to formatType, there is no default after I "fixed" the image issue I got more errors which is why I added the default case, I'm just not sure how you want to handle an unknown, the error was that formatType wasn't returning a string.

Production build 0.71.5 2024