mindee/mindee-api-php

Exception when processing a JPG image blob using sourceFromBytes()

superwave1999 opened this issue · 2 comments

Prerequisites

  • Reproduced the problem or exposed a new need
  • Checked the GitHub existing issues

Description

I'm sending a JPG image that is under the maximum file size limit using sourceFromBytes().
The image has been modified using Imagick, and instead of saving it to disk, I pass it directly to the function.
Using the online UI at platform.mindee.com, the modified image is parsed correctly when uploaded.

Once the request is sent to your servers, the returned response is

{"data":false,"code":0}

this response triggers an error in MindeeHttpException::createErrorObj() when the $response variable is false and is being evaluated as an array in line 115, array_key_exists.

So the two problems are:

  • Code 0 response doesn't seem to be handled correctly.
  • There is a different behaviour between your web UI and this library using the same image.

Steps to Reproduce

  1. Load image into a string variable
  2. Send that string using sourceFromBytes()

Expected behavior:

We expect the error to be handled correctly with an appropriate type and text.

Actual behavior:

A (suspected) error when generating the tmp file from the string triggers a strange response from your API that subsequently breaks the library.

Reproduces how often:

100%

Versions

Ubuntu 22.04
PHP 8.1

Additional Information

Although our production PHP configuration is modified the PHP configuration on my dev machine is the default from sources. Same issue happens both places.

Hello, thank you for raising this. A fix is in the works.

Fixed in #37.