hkulekci / qdrant-php

Qdrant is a vector similarity engine & vector database. It deploys as an API service providing search for the nearest high-dimensional vectors. With Qdrant, embeddings or neural network encoders can be turned into full-fledged applications for matching, searching, recommending, and much more!
MIT License
93 stars 21 forks source link

sendRequest return null, new Response($res); will report error #57

Open stingbo opened 1 month ago

stingbo commented 1 month ago
  public function execute(RequestInterface $request): Response
    {
        $res = $this->transport->sendRequest($request);
        $statusCode = $res->getStatusCode();
        if ($statusCode >= 400 && $statusCode < 500) {
            $errorResponse = new Response($res);
            throw (new InvalidArgumentException(
                $errorResponse['status']['error'] ?? 'Invalid Argument Exception',
                $statusCode)
            )->setResponse($errorResponse);
        } elseif ($statusCode >= 500) {
            $errorResponse = new Response($res);
            throw (new ServerException(
                $errorResponse['status']['error'] ?? '500 Interval Service Error',
                $statusCode)
            )->setResponse($errorResponse);
        }

        return new Response($res);
    }

if sendRequest return null, new Response($res); will report error

hkulekci commented 1 month ago

Hello @stingbo, thanks for reporting. I will check soon! Please don't hesitate to create another issue if you face another problem.

hkulekci commented 3 weeks ago

Hello @stingbo, technically sendRequest could not return null according to implementation.

class Transport implements ClientInterface
{
    ....
    public function sendRequest(RequestInterface $request): ResponseInterface
    {
        $request = $this->prepareHeaders($request);

        return $this->client->sendRequest($request);
    }
}

So, for this reason, we don't need to check, especially here, for a null value. Let's close the ticket if you don't have any objection.