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

Increase parser arrayLimit to 100 #7430

Merged
merged 2 commits into from Aug 13, 2020

Conversation

drj17
Copy link
Contributor

@drj17 drj17 commented Aug 11, 2020

Description of what you did:

Updated the arrayLimit in the parser to 100 (arbitrarily). There might be a better number to use here, but it's causing issues when trying to do a where [field]_in query with a list of more than 20 items (see the tagged issue) using GraphQL. You could theoretically use Infinite here but that might open things up to abuse.

Fix #5995

@codecov
Copy link

codecov bot commented Aug 11, 2020

Codecov Report

Merging #7430 into master will decrease coverage by 0.01%.
The diff coverage is 2.38%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7430      +/-   ##
==========================================
- Coverage   26.23%   26.21%   -0.02%     
==========================================
  Files        1131     1131              
  Lines       15431    15440       +9     
  Branches     2442     2438       -4     
==========================================
  Hits         4048     4048              
- Misses       9564     9576      +12     
+ Partials     1819     1816       -3     
Flag Coverage Δ
#front 18.25% <2.38%> (-0.02%) ⬇️
#unit 53.14% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...pi-admin/admin/src/components/GlobalStyle/index.js 0.00% <ø> (ø)
...nt-manager/admin/src/components/CustomTable/Row.js 0.00% <ø> (ø)
.../admin/src/components/InputJSONWithErrors/index.js 0.00% <0.00%> (ø)
...ent-manager/admin/src/components/InputUID/index.js 0.00% <0.00%> (ø)
...ponents/MediaPreviewList/StyledMediaPreviewList.js 0.00% <ø> (ø)
...-manager/admin/src/components/Wysiwyg/constants.js 0.00% <ø> (ø)
...nt-manager/admin/src/components/Wysiwyg/helpers.js 0.00% <0.00%> (ø)
...tent-manager/admin/src/components/Wysiwyg/index.js 0.00% <0.00%> (ø)
...er/admin/src/components/WysiwygWithErrors/index.js 0.00% <0.00%> (ø)
...uilder/admin/src/components/ComponentCard/index.js 0.00% <ø> (ø)
... and 12 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e3d6ce1...5d6cf98. Read the comment docs.

@derrickmehaffy
Copy link
Member

@alexandrebodin is this something the user can just customize themselves within the middleware.js config file?

@@ -16,7 +16,7 @@ const addQsParser = app => {
get() {
const qstr = this.querystring;
const cache = (this._querycache = this._querycache || {});
return cache[qstr] || (cache[qstr] = qs.parse(qstr, { depth: 20 }));
return cache[qstr] || (cache[qstr] = qs.parse(qstr, { arrayLimit: 100, depth: 20 }));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should alow passing some options so we can have a sensible default and leave the rest to the user.

We can achieve this by adding a queryStringParser to strapi.config.middleware.settings.parser and setting the default in the default.json and passing the option to the addQsParser fn. We need to make sure we do not pass the option to koa-body though.

Copy link
Member

@alexandrebodin alexandrebodin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make it even more flexible for the users

packages/strapi/lib/middlewares/parser/index.js Outdated Show resolved Hide resolved
packages/strapi/lib/middlewares/parser/index.js Outdated Show resolved Hide resolved
@alexandrebodin alexandrebodin added source: core:strapi Source is core/strapi package issue: enhancement Issue suggesting an enhancement to an existing feature labels Aug 12, 2020
@alexandrebodin alexandrebodin added this to the 3.1.4 milestone Aug 12, 2020
@alexandrebodin
Copy link
Member

@drj17 @derrickmehaffy can you add work together on adding this to the doc :)

Signed-off-by: David Janas <davidjanasr@gmail.com>
@drj17 drj17 force-pushed the fix/graphql_where_in branch 2 times, most recently from 8ce70b8 to 91cda82 Compare August 13, 2020 15:35
@drj17
Copy link
Contributor Author

drj17 commented Aug 13, 2020

Hi @derrickmehaffy, I took a first pass at adding it to the docs. Let me know if there are any changes you'd like me to make!

Whoops. Looks like prettier messed up my formatting :(

Signed-off-by: David Janas <davidjanasr@gmail.com>
@fellz
Copy link

fellz commented Aug 13, 2020

release 3.1.4 please! i am waiting for bug fix a week already....

@drj17
Copy link
Contributor Author

drj17 commented Aug 13, 2020

release 3.1.4 please! i am waiting for bug fix a week already....

I posted a work-around here if you need a quick fix

Copy link
Member

@alexandrebodin alexandrebodin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really good to me ! nice job :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: enhancement Issue suggesting an enhancement to an existing feature source: core:strapi Source is core/strapi package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GraphQL: Selecting more than 20 items in _in filter results in ER_BAD_FIELD_ERROR
4 participants