Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal Requests returning inconsistent results #1108

Open
whoisgregg opened this issue Jul 7, 2016 · 1 comment
Open

Internal Requests returning inconsistent results #1108

whoisgregg opened this issue Jul 7, 2016 · 1 comment

Comments

@whoisgregg
Copy link

I am making internal requests to Dingo and experiencing inconsistent results. "Example-fied" code:

$response = $this->api->get('/api/v1/endpoint', [
    'foreign_key_id' => $request->input('foreign_key_id'),
    'include' => 'relationship_1,relationship_2.relationship_2_1',
]);
print_r($response);

This endpoint is setup to return a paginated collection of objects. "Example-fied" code:

// queries the model 
$objects = $model->paginate(100);
return $this->response->paginator($objects, new $this->classTransformer());

In the vast majority of cases, I get the response I expect which is a Paginator Object:

Illuminate\\Pagination\\LengthAwarePaginator Object
(
    [total:protected] => 1
    [lastPage:protected] => 1
    [items:protected] => Illuminate\\Database\\Eloquent\\Collection Object
        (
            [items:protected] => Array
                (
                    [0] => App\\Endpoint Object
[snipped rest of result]

However, on some rare cases, what is returned instead is a Response Object wrapper around the Paginator Object:

Dingo\\Api\\Http\\Response Object
(
    [exception] => 
    [binding:protected] => 
    [original] => Illuminate\\Pagination\\LengthAwarePaginator Object
        (
            [total:protected] => 1
            [lastPage:protected] => 1
            [items:protected] => Illuminate\\Database\\Eloquent\\Collection Object
                (
                    [items:protected] => Array
                        (
                            [0] => App\\Endpoint Object
[snipped rest of result]

My code expects a Paginator object and loops through the result. So, whenever it doesn't get a Paginator, users experience a "whoops something went wrong" page and the error log shows a ErrorException: Trying to get property of non-object type error. In every report of the error page, refreshing the page immediately "fixes" the problem. Meaning, in other words, that the exact same query on the exact same data a few seconds later returns the expected response.

There's nothing in my code to switch between these types of responses. The same code querying the same tables with the same underlying data seems to randomly (and rarely) return a different type of response.

I've searched the reported issues here already and didn't see anything similar so I'm reporting this in the hopes that folks more experienced with Dingo can identify what the underlying issue is.

Thanks! :)

@hskrasek
Copy link
Member

@whoisgregg Is this happening with the current version of Dingo/API? 1.0.0-beta3?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants