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

Queries with sort but no fields and filter objects fail #530

fra967 opened this Issue Jan 23, 2019 · 1 comment


None yet
2 participants
Copy link

fra967 commented Jan 23, 2019

A query retrieving an ordered list of records fails if both fields and filter objects are empty

For example this query returns 500{}&sort={"publicationDate":-1}

While these return valid data (note that one between fields and filter is specified){"title":1}&sort={"publicationDate":-1}{"published.state":"published"}&fields={}&sort={"publicationDate":-1}

The issue occurs only when sorting is applied

The following error is logged

    TypeError: Cannot destructure property `metadata` of 'undefined' or 'null'.
        at Promise.then.then.then (/var/www/api-v4/api/node_modules/@dadi/api/dadi/lib/model/collections/get.js:116:11)

Package details

API 4.4.4 on node 8.15.0
Does not occur on API 2.3.2 and 3.2.2


This comment has been minimized.

Copy link
Member Author

fra967 commented Jan 23, 2019

Some more details that seem to lead to an issue with composition

(always assuming fields={} and some sort)

The filter would lead to a 500 whenever it includes a composed collection{"publications.language":"en"}&fields={}&sort={"publicationDate":-1}

The case described above, when the presence of the filter returns a successful query, occurs when the filter is applied to a field in the queried collection (published.state)

Also, the issue does not occur when passing &compose=false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment