SciCatProject / SciCatProject/backend
Filter in headers is not parsed to comply with mongo syntax
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 27
- Forks
- 37
- Avg merge
- 17h 32m
- Merged PRs (30d)
- 38
Description
Issue Name
Filter in headers is not parsed to comply with mongo syntax
Summary
When passing a filter in a request header, if the filter has mongo-specific syntax, the request fails
Steps to Reproduce
curl -X GET --header 'Accept: application/json' --header 'Filter: {"where":{"sourceFolder":{"inq":["something"]}},"fields": {"pid":1,"size":1,"sourceFolder":1}}' 'http://localhost:3000/api/v3/Datasets'
Current Behaviour
the command above returns 500, because the "inq" in the filter is not converted to "$in" required by mongo (while it correctly happens if the filter is set as a query param)
Expected Behaviour
should return 200 having applied the filter
Extra Details
One solution could be this, but in general, it might make sense to add a middleware (e.g. here) acting on all requests which, in case there is a filter in the headers, it adds it as a query parameter.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the curl request against the Datasets endpoint, then inspect src/datasets/datasets.controller.ts around lines 110-112 and the common middleware entry point suggested in the issue. Compare header and query-parameter filter handling. Done means the shown Mongo-style header filter returns 200 and is applied correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100