Error if no API key is set

Created on 7 November 2024, 16 days ago

Problem/Motivation

If you don't select an API key (eg. on local installations) a save on a node using unstructured fails with error:

Error: Typed property Drupal\unstructured\UnstructuredApi::$apiKey must not be accessed before initialization in Drupal\unstructured\UnstructuredApi->makeRequest() (line 126 of modules/contrib/unstructured/src/UnstructuredApi.php).

Proposed resolution

Make sure that $this->apiKey is initialized at line 50 of UnstructuredApi.php, eg.:

if ($key) {
      $this->apiKey = $keyRepository->getKey($key)->getKeyValue();
    }
    else {
     // Initialize with some value here
      $this->apiKey = '';
    }
🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇦🇹Austria roromedia Linz

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