owncloud / libre-graph-api-php

PHP Client for the LibreGraph API
Apache License 2.0
1 stars 0 forks source link

listAllDrivesWithHttpInfo function fails to catch and null response exception #4

Closed S-Panta closed 11 months ago

S-Panta commented 1 year ago

If the URL is in the wrong format, response would be null and this function doesn't throw any exception but returns null. response as null makes no sense. Thus the function should handle this exception.

Note: I have used [ocis-php-sdk] to reproduce the error. https://github.com/owncloud/ocis-php-sdk

Steps to reproduce

Create an Ocis object using the service Url with an extra slash in it and an access token.

$ocis = new Ocis('https://example.ocis.com/', $accessToken);

The response will be returned as null.

Expected result

The function should handle the error.

individual-it commented 1 year ago

The problem here is if the server returns a 200 response but the content is not JSON decodeble e.g. in https://github.com/owncloud/libre-graph-api-php/blob/main/lib/Api/MeDrivesApi.php#L203 json_decode returns null in that case and that is propagated upwards

individual-it commented 1 year ago

should be fixed by https://github.com/OpenAPITools/openapi-generator/pull/16879

individual-it commented 12 months ago

@S-Panta please retest, and check if the issue is fixed

S-Panta commented 12 months ago

Somehow, the body of the response of listAllDrivesWithHttpInfo() function is giving html as body response when the wrong format of URL is provided. Json can't decode that response body and it returns null as it's output. I am not if the issue is fixed. It stills give back null response.

individual-it commented 12 months ago

@S-Panta exactly and in the current version of this library (after https://github.com/OpenAPITools/openapi-generator/pull/16879) the function should not return null but throw an JsonException when it cannot decode the output. Do you run the most recent version of this library? Please check your package.json , what version of libre-graph-api-php are you using? maybe rerun composer update?

S-Panta commented 12 months ago

I used the latest generation and the response is still Null.

amrita-shrestha commented 11 months ago

I used the latest generation and the response is still Null.

The current image doesn't include fixed PR. I made bump PR : https://github.com/owncloud/libre-graph-api/pull/143 After this Pr merge you can try

individual-it commented 11 months ago

The bump did not do anything, it did not produce any different output

individual-it commented 11 months ago

the issue was that we haven't applied the fix of https://github.com/OpenAPITools/openapi-generator/pull/17120 in the template used in the generator, should be done by https://github.com/owncloud/libre-graph-api/pull/146

individual-it commented 11 months ago

@S-Panta please confirm if the issue is really fixed

S-Panta commented 11 months ago

It is fixed.