You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: patch:multi only patches 10 items with default pagination #363
Multi-patch without $limit in params.query results in an incomplete operation, because filterQuery adds the default $limit: -1 to the request. Not sure if this problem exists in multi-remove as well.
I'll add this to feathers-sequelize and do a hacky PR for now. But the problem goes deeper, I think. I have something in mind for @feathersjs/adapter-tests and @feathersjs/adapter-commons:
Question 1: Is this something we should add to @feathersjs/adapter-tests? I saw there are tests for multiple items (count = 2) but not for many items, at least > 10.
I find this behavior of filterQuery from @feathersjs/adapter-commons quite confusing, although I understand, why it is like it is.
In another project I ended up deleting the default $limit: 10 from filterQuery(params) if params.query.$limit is not the same. Not the nicest solution, but the quickest. Question 2: Is this maybe worth a property for second options argument of filterQuery? Something like: filterQuery(params, { addDefaultLimit: false }?
I will look into this in feathers-sequelize for now. @daffl if you answered one of the two bold questions with "yes", I would be happy to help. Just let me know!
Thanks for your quick response! Yep, it does. I've added this in a before-hook for multi-patches.
Do you think this should stay as it is? for find the pagination is totally necessary, but for multi-patches I would say it's counter intuitive.
If you think we should leave this as is, maybe we should add a note to the readme?:
If setting paginate:false works as expected, then I do think it should stay as is. But it should also be mentioned in the README. Good catch!
It's primarily a security concern IMO. Otherwise someone can overload the server/database by patching 1 million+ rows.
Be careful with that hook you mentioned in your comment, because it is susceptible to the "attack" above. Anything that allows the client to potentially disable pagination is a security risk.
Hm, I was expecting this to work as intended (patching/removing all items) because the _getOrFind explicitly always sets paginate: false: https://github.com/feathersjs-ecosystem/feathers-sequelize/blob/master/lib/index.js#L114 but as pointed out, the filterQuery is causing the problem here. I wonder if other adapters do this differently and how a test for this would look like.
It's totally a security issue. Maybe it's something for disablePagination from feathers-hooks-common (add 'patch' to checkContext)?
I understand the concerns. But patching the default amount of items and leave the rest as is leaves you behind with headaches. Maybe a better way would be to throw a BadRequest if no $limit and no paginate: false is set and the idList.length is larger than the default $limit?
A generic test would start with more than 10 items. The problem is, that @feathersjs/adapter-tests takes the servicePath. One option would be to fail, if the service doesn't have a options.paginate property. Another option would be to clone the service and add the options.paginate property to the cloned instance. But I haven't looked into @feathersjs/adapter-tests that much.
Since the patch returns all items that were patched, we could compare the length of items.
What do you think @daffl? Should I come up with a PR for @feathersjs/adapter-tests?
Activity
DaddyWarbucks commentedon Apr 7, 2021
Does setting
paginate: falsework?fratzinger commentedon Apr 7, 2021
Thanks for your quick response! Yep, it does. I've added this in a before-hook for multi-patches.
Do you think this should stay as it is? for
findthe pagination is totally necessary, but for multi-patches I would say it's counter intuitive.If you think we should leave this as is, maybe we should add a note to the readme?:
DaddyWarbucks commentedon Apr 7, 2021
If setting
paginate:falseworks as expected, then I do think it should stay as is. But it should also be mentioned in the README. Good catch!It's primarily a security concern IMO. Otherwise someone can overload the server/database by patching 1 million+ rows.
For example,
Be careful with that hook you mentioned in your comment, because it is susceptible to the "attack" above. Anything that allows the client to potentially disable pagination is a security risk.
daffl commentedon Apr 7, 2021
Hm, I was expecting this to work as intended (patching/removing all items) because the
_getOrFindexplicitly always setspaginate: false: https://github.com/feathersjs-ecosystem/feathers-sequelize/blob/master/lib/index.js#L114 but as pointed out, thefilterQueryis causing the problem here. I wonder if other adapters do this differently and how a test for this would look like.fratzinger commentedon Apr 7, 2021
@DaddyWarbucks
It's totally a security issue. Maybe it's something for
disablePaginationfromfeathers-hooks-common(add'patch'tocheckContext)?I understand the concerns. But patching the default amount of items and leave the rest as is leaves you behind with headaches. Maybe a better way would be to throw a
BadRequestif no$limitand nopaginate: falseis set and theidList.lengthis larger than the default$limit?I also thought like @daffl because
_getOrFindsetspaginate: false. TheidList(https://github.com/feathersjs-ecosystem/feathers-sequelize/blob/master/lib/index.js#L232) has the full list of ids (for the 1 million+ rows). So if it should stay as is, I think it's worth considering to integrate the filter to the request ofidList.@daffl
A generic test would start with more than 10 items. The problem is, that
@feathersjs/adapter-teststakes the servicePath. One option would be to fail, if the service doesn't have aoptions.paginateproperty. Another option would be to clone the service and add theoptions.paginateproperty to the cloned instance. But I haven't looked into@feathersjs/adapter-teststhat much.Since the
patchreturns all items that were patched, we could compare the length of items.What do you think @daffl? Should I come up with a PR for
@feathersjs/adapter-tests?DaddyWarbucks commentedon Nov 16, 2022
Maybe relevant: #405
fratzinger commentedon Apr 3, 2023
This is completed in dove.