8000 OData $filter: unsupported function results in 500 error · Issue #711 · getodk/central · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

OData $filter: unsupported function results in 500 error #711

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

Closed
matthew-white opened this issue Aug 21, 2023 · 0 comments · Fixed by getodk/central-backend#1236
Closed
Assignees
Labels
backend Requires a change to the API server bug nicer error More understandable error messages

Comments

@matthew-white
Copy link
Member

A user on v2023.3.1 tried to use contains() in the OData $filter query parameter, which resulted in an error in Sentry. We don't support the OData contains() function, which causes methodCall() in odata-filter.js to return undefined, then I think odataFilter() as a whole to return undefined:

https://github.com/getodk/central-backend/blob/83e453326c9aeded6297c1ef5af63aa0efc782b4/lib/data/odata-filter.js#L27-L34

Slonik then throws an error about passing undefined to a sql`` template string:

InvalidInputError: SQL tag cannot be bound an undefined value.
  File "/usr/odk/node_modules/slonik/dist/src/factories/createSqlTag.js", line 27, col 19, in sql
    throw new errors_1.InvalidInputError('SQL tag cannot be bound an undefined value.');
  File "/usr/odk/lib/model/query/submissions.js", line 309, col 13, in _export
    return sql`
  File "/usr/odk/lib/model/query/submissions.js", line 348, col 10, in <anonymous>
    stream(_export(formId, draft, keyIds, options))
  File "/usr/odk/lib/model/container.js", line 30, col 33, in Object.module.<computed> [as streamForExport]
    const result = fn(...args)(container);
  File "/usr/odk/lib/resources/odata.js", line 68, col 25, in <anonymous>
    Submissions.streamForExport(form.id, draft, undefined, options),
  File "/usr/odk/node_modules/slonik/dist/src/factories/createSqlTag.js", in runMicrotasks
  File "node:internal/process/task_queues", line 96, col 5, in processTicksAndRejections

Instead of returning undefined, I think odataFilter() should throw an OData-related Problem if passed a function that it doesn't support. We throw a Problem in other cases in which we aren't able to handle the filter expression.

@matthew-white matthew-white transferred this issue from getodk/central-backend Sep 18, 2024
@matthew-white matthew-white added the backend Requires a change to the API server label Sep 19, 2024
@github-project-automation github-project-automation bot moved this to 🕒 backlog in ODK Central Oct 28, 2024
@matthew-white matthew-white moved this from 🕒 backlog to ✏️ in progress in ODK Central Oct 28, 2024
@github-project-automation github-project-automation bot moved this from ✏️ in progress to ✅ done in ODK Central Oct 30, 2024
@matthew-white matthew-white added the nicer error More understandable error messages label Nov 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Requires a change to the API server bug nicer error More understandable error messages
Projects
Status: ✅ done
Development

Successfully merging a pull request may close this issue.

2 participants
0