Getting an error on chapgpt configure page.

Created on 23 November 2023, 7 months ago
Updated 13 May 2024, about 1 month ago

Problem/Motivation

Getting an error on reaching chapgpt configuration page (/admin/config/openai/chatgpt). This happens when their is no API Key present in the OpenAI Settings page (/admin/config/openai/settings). Same things happening to admin/config/openai/dalle, admin/config/openai/openai-dblog/settings, admin/config/openai/openai-prompt and admin/config/openai/tts pages.

The website encountered an unexpected error. Please try again later.

OpenAI\Exceptions\ErrorException: Invalid authorization header in OpenAI\Transporters\HttpTransporter->throwIfJsonError() (line 131 of /var/www/html/vendor/openai-php/client/src/Transporters/HttpTransporter.php).
OpenAI\Transporters\HttpTransporter->requestObject(Object) (Line: 28)
OpenAI\Resources\Models->list() (Line: 86)
Drupal\openai\OpenAIApi->getModels() (Line: 130)
Drupal\openai\OpenAIApi->filterModels(Array) (Line: 58)
Drupal\openai_chatgpt\Form\ChatGptForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 536)
Drupal\Core\Form\FormBuilder->retrieveForm('openai_chatgpt_form', Object) (Line: 283)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 592)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
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: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->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: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Steps to reproduce

Fresh install OpenAI Core and OpenAI ChatGPT Explorer modules. Go to the Configure page (admin/config/openai/chatgpt) of OpenAI ChatGPT Explorer module by clicking on the Configure button on the modules listing page.

Proposed resolution

Instead of causing a php error, sent the user to OpenAI Settings page (/admin/config/openai/settings) for setting the API key. Or put a message on top of the ChatGPT settings page saying something like, API key must be set for further activities.

🐛 Bug report
Status

Fixed

Version

1.0

Component

User interface

Created by

🇮🇳India sijumpk

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

Comments & Activities

Production build 0.69.0 2024