Migrations fail on Orange DAM API "200 OK" responses during subtitle retrieval.

Created on 26 June 2023, about 1 year ago
Updated 7 July 2023, 12 months ago

Problem/Motivation

New issue with migrations, not seen before. Now when migrating, everything works ok for a while and then we get this message:

In OrangeDamApi.php line 667:

Unexpected Orange DAM API response. Received 200 with message "OK."

And the migration processes are stopped. this means I cannot complete migrations in the dev environment.

The code in question seems to treat an empty subtitle response as an error:

      if (empty($content)) {
        throw new \Exception(sprintf(
          'Unexpected Orange DAM API response. Received %s with message "%s."',
          $response->getStatusCode(),
          $response->getReasonPhrase(),
        ));
      }

It seems that if a 200 OK response is received, an error should not be thrown even if the contents are empty as we should expect that the emptiness of the content is an accurate reflection of affairs.

In any case, any time an item is encountered whose subtitles are empty, the migration is interrupted.

I suggest this code be changed to:

      if ($response->getStatusCode() != 200) {
        throw new \Exception(sprintf(
          'Unexpected Orange DAM API response. Received %s with message "%s."',
          $response->getStatusCode(),
          $response->getReasonPhrase(),
        ));
      }

(Do we have access to HTTP_ERROR_EXCEPTION or something similar from Guzzle?)

Then, further, in the following section:

      if (!isset($content[0]->content)) {
        $this->logger->error('Unable to retrieve subtitle data for item :item.', [
          ':item' => $record_id,
        ]);
        return FALSE;
      }
      return $content[0];

We should make an allowance for the subtitles being empty. If JFKL feel that a warning or some kind of logging/notification should be in place for this, then we can implement that, but I don’t think empty subtitles are necessarily an exception/error.

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States apotek

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

Comments & Activities

Production build 0.69.0 2024