CMR-10296: Adding arrayLimit to qs parser to increase the array limit without indices#389
Merged
william-valencia merged 4 commits intomasterfrom Feb 5, 2025
Merged
CMR-10296: Adding arrayLimit to qs parser to increase the array limit without indices#389william-valencia merged 4 commits intomasterfrom
william-valencia merged 4 commits intomasterfrom
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #389 +/- ##
==========================================
+ Coverage 88.39% 88.42% +0.02%
==========================================
Files 24 24
Lines 1215 1218 +3
Branches 269 269
==========================================
+ Hits 1074 1077 +3
Misses 141 141 ☔ View full report in Codecov by Sentry. |
src/app.ts
Outdated
| // Anything over 100 would error out because indices are added. See CMR-10296 and | ||
| // https://github.com/ljharb/qs for more details. | ||
| app.set("query parser", function (str: string) { | ||
| return qs.parse(str, { arrayLimit: 10000 }); |
Contributor
There was a problem hiding this comment.
Array limit is 10,000 but, comment is 100?
Contributor
Author
There was a problem hiding this comment.
Sorry about that. Was testing 10000.
dpesall
approved these changes
Feb 4, 2025
macrouch
approved these changes
Feb 5, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
What is the feature?
Currently, the default array limit of the qs parser in express is set to 20. When arrays with more than 20 items are passed to CMR STAC as query parameters(for coodinates of an intersects parameter), array indices are added. The CMR STAC code cannot handle the array indices so it errors out.
What is the Solution?
Increasing the array limit of the default qs parser in express to 100. This will allow coordinates of up to 100 points.
What areas of the application does this impact?
CMR STAC
Testing
Reproduction steps
You can try the following on a browser locally or in PROD with the proper URL:
https://cmr.earthdata.nasa.gov/stac/LPCLOUD/search?datetime=2024-01-01T00:00:00Z/2024-01-31T23:59:59Z&collections[0]=HLSS30_2.0&intersects[type]=Polygon&intersects[coordinates][0][0][0]=-48.31876570764564&intersects[coordinates][0][0][1]=-24.13235588091331&intersects[coordinates][0][1][0]=-48.319182157887525&intersects[coordinates][0][1][1]=-24.135649639167937&intersects[coordinates][0][2][0]=-48.2842003375668&intersects[coordinates][0][2][1]=-24.159843492656776&intersects[coordinates][0][3][0]=-48.26087912402002&intersects[coordinates][0][3][1]=-24.122474097202897&intersects[coordinates][0][4][0]=-48.259074506305325&intersects[coordinates][0][4][1]=-24.110310854137083&intersects[coordinates][0][5][0]=-48.268652861869185&intersects[coordinates][0][5][1]=-24.095231896596758&intersects[coordinates][0][6][0]=-48.273511448024976&intersects[coordinates][0][6][1]=-24.09662582428146&intersects[coordinates][0][7][0]=-48.2842003375668&intersects[coordinates][0][7][1]=-24.086361092375142&intersects[coordinates][0][8][0]=-48.28600495528215&intersects[coordinates][0][8][1]=-24.081038315106454&intersects[coordinates][0][9][0]=-48.28142400262118&intersects[coordinates][0][9][1]=-24.076095538322363&intersects[coordinates][0][10][0]=-48.28364507057779&intersects[coordinates][0][10][1]=-24.070645589226345&intersects[coordinates][0][11][0]=-48.29280697589971&intersects[coordinates][0][11][1]=-24.079390744017203&intersects[coordinates][0][12][0]=-48.29655502807688&intersects[coordinates][0][12][1]=-24.07977095461004&intersects[coordinates][0][13][0]=-48.295583310845984&intersects[coordinates][0][13][1]=-24.08433339376434&intersects[coordinates][0][14][0]=-48.30169124772749&intersects[coordinates][0][14][1]=-24.08293933236135&intersects[coordinates][0][15][0]=-48.3040511324312&intersects[coordinates][0][15][1]=-24.0845868578446&intersects[coordinates][0][16][0]=-48.298914912781214&intersects[coordinates][0][16][1]=-24.08876894281238&intersects[coordinates][0][17][0]=-48.30058071374884&intersects[coordinates][0][17][1]=-24.089909487754852&intersects[coordinates][0][18][0]=-48.30641101713553&intersects[coordinates][0][18][1]=-24.086614552446946&intersects[coordinates][0][19][0]=-48.31140842003842&intersects[coordinates][0][19][1]=-24.096879264048766&intersects[coordinates][0][20][0]=-48.310020252565636&intersects[coordinates][0][20][1]=-24.10068080039386&intersects[coordinates][0][21][0]=-48.31876570764564&intersects[coordinates][0][21][1]=-24.13235588091331
Make sure the request doesn't error out with:
{"errors":["Oops! Something has gone wrong. We have been alerted and are working to resolve the problem. Please try your request again later."]}
Attachments
Please include relevant screenshots or files that would be helpful in reviewing and verifying this change.
Checklist