Problem/Motivation

After upgrading to version 2.1.2, I started getting this error when I would try to edit a node:

TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in in_array() (line 47 of modules/contrib/chatgpt_plugin/chatgpt_plugin.module).
chatgpt_plugin_form_alter() (Line: 545)
Drupal\Core\Extension\ModuleHandler->alter() (Line: 838)
Drupal\Core\Form\FormBuilder->prepareForm() (Line: 282)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
Drupal\Core\Controller\FormController->getContentResult()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 163)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 74)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 58)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 686)
Drupal\Core\DrupalKernel->handle() (Line: 19)

This didn't happen before the upgrade. TIA.

CommentFileSizeAuthor
#5 TypeError-3355852-5.patch701 byteswil2091

Comments

bogdog400 created an issue. See original summary.

anup.sinha’s picture

Hi @bogdog400, I have done an update in the configuration page. Now you can choose content types for which you want to enable this AI assistance feature. Just go to the OpenAI configuration (/admin/config/chatgpt) page and select the content types and then save. This should fix your error.

Thanks & Regards,
Anup

bogdog400’s picture

Thx!

anup.sinha’s picture

Status: Active » Closed (works as designed)
wil2091’s picture

StatusFileSize
new701 bytes

Still can replicate the same error if I don't select any of the content types or don't save the config form.

Adding a simple patch for this fix.

anup.sinha’s picture

Hi @wil2091, thanks for the patch. It is now included in the latest release.

Thanks & Regards,
Anup