OpenAI CKEditor - On error, content should not be replaced

Created on 29 November 2023, about 1 year ago
Updated 18 April 2024, 8 months ago

Problem/Motivation

When using "Summarize" and having text selected, if there is an API error the text is replaced with the error.

Steps to reproduce

The website encountered an unexpected error. Please try again later.<br><br><em class="placeholder">Symfony\Component\HttpKernel\Exception\ControllerDoesNotReturnResponseException</em>: The controller must return a &quot;Symfony\Component\HttpFoundation\Response&quot; object but it returned a string (&quot;&quot;). in <em class="placeholder">()</em> (line <em class="placeholder">98</em> of <em class="placeholder">core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php</em>). <pre class="backtrace">Symfony\Component\HttpKernel\HttpKernel-&gt;handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel-&gt;handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session-&gt;handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle-&gt;handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache-&gt;pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache-&gt;handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware-&gt;handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware-&gt;handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel-&gt;handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel-&gt;handle(Object) (Line: 19)
</pre>


My errors were as follows
- There was an issue obtaining a response from OpenAI. The error was Connection refused for URI https://api.openai.com/v1/chat/completions.
-

Warning: Undefined array key "function" in Drupal\Core\Utility\Error::getLastCaller() (line 150 of /var/www/html/docroot/core/lib/Drupal/Core/Utility/Error.php)
#0 /var/www/html/docroot/core/includes/bootstrap.inc(164): _drupal_error_handler_real(2, 'Undefined array...', '/var/www/html/d...', 150)
#1 /var/www/html/docroot/core/lib/Drupal/Core/Utility/Error.php(150): _drupal_error_handler(2, 'Undefined array...', '/var/www/html/d...', 150)

- Symfony\Component\HttpKernel\Exception\ControllerDoesNotReturnResponseException: The controller must return a "Symfony\Component\HttpFoundation\Response" object but it returned a string (""). in () (line 98 of /var/www/html/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php).

Warning: Undefined array key "function" in Drupal\Core\Utility\Error::getLastCaller() (line 150 of /var/www/html/docroot/core/lib/Drupal/Core/Utility/Error.php)
#0 /var/www/html/docroot/core/includes/bootstrap.inc(164): _drupal_error_handler_real(2, 'Undefined array...', '/var/www/html/d...', 150)
#1 /var/www/html/docroot/core/lib/Drupal/Core/Utility/Error.php(150): _drupal_error_handler(2, 'Undefined array...', '/var/www/html/d...', 150)

Proposed resolution

Check if the API calls is successful and only then replace, else maybe just a JS alert?

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Needs review

Version

1.0

Component

OpenAI CKEditor

Created by

πŸ‡ΊπŸ‡ΈUnited States NicholasS

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024