CMR-10200: Fixing stringifyQuery by using qs's version #369
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.
When using cmr-stac and specifying an intersects Point parameter via pystac, cmr-stac responds with an "APIError: {"errors":["Oops! Something has gone wrong. We have been alerted and are working to resolve the problem. Please try your request again later."]}"
What is actually happening is that the initial call is succeeding, but pystac is trying to get all the items, and cmr-stac fails when the next link is called. The next link is specified as follows: http://localhost:3000/stac/LPCLOUD/search?datetime=2024-01-01T00%3A00%3A00Z%2F2024-03-31T23%3A59%3A59Z&collections=HLSS30_2.0&intersects%5Btype%5D=Point&intersects%5Bcoordinates%5D=-105.97%2C35.78&cursor=eyJqc29uIjoiW1wibHBjbG91ZFwiLDE3MDkwNTY0NTAxMzAsMjg4MTI1MDg4OF0iLCJ1bW0iOiJbXCJscGNsb3VkXCIsMTcwOTA1NjQ1MDEzMCwyODgxMjUwODg4XSJ9
The failing part is the "intersects[coordinates]=-105.97,35.78" which cmr-stac's stringifyQuery function generates. On the next call, cmr-stac interprets this as a string although it is expecting an array and errors out.
The solution is to modify the stringifyQuery function to actually return an array, which is what cmr-stac is expecting. Luckily the "qs" library has such a function that does this well.