-
Notifications
You must be signed in to change notification settings - Fork 56
Fix double-encoding of intersects in GET requests #337
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
Conversation
Codecov ReportBase: 85.50% // Head: 85.87% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #337 +/- ##
==========================================
+ Coverage 85.50% 85.87% +0.37%
==========================================
Files 11 11
Lines 800 800
==========================================
+ Hits 684 687 +3
+ Misses 116 113 -3
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
f61b7c9 to
b739a1d
Compare
|
I'm converting this to draft because I'd like to test it on a real-world server implementation first. For #362, I couldn't url encode the parameter when testing against the Planetary Computer. I'd like to know whether that's a server bug, which will determine whether we url encode the intersects parameter in this PR. |
|
To keep this moving, and in liu of a production system to run a real-world test against, I tested this against stac-utils/stac-fastapi@97b0911 with the following patch: diff --git a/stac_fastapi/pgstac/stac_fastapi/pgstac/core.py b/stac_fastapi/pgstac/stac_fastapi/pgstac/core.py
index 9b194f7..68d7620 100644
--- a/stac_fastapi/pgstac/stac_fastapi/pgstac/core.py
+++ b/stac_fastapi/pgstac/stac_fastapi/pgstac/core.py
@@ -358,6 +358,9 @@ class CoreCrudClient(AsyncBaseCoreClient):
"""
request = kwargs["request"]
query_params = str(request.query_params)
+ import json
+ import urllib.parse
+ print(json.loads(urllib.parse.unquote_plus(kwargs["intersects"][0])))
# Kludgy fix because using factory does not allow alias for filter-lang
if filter_lang is None:I then ran: cd stac-fastapi && docker-compose up &
cd ../pystac-client && stac-client search --method GET http://localhost:8082 --intersects '{"type":"Point","coordinates":[-105.1019,40.1672]}'Relevant output: I'm going to call that good for now, and mark this PR as ready-to-review. |
f3895f6 to
27c7df3
Compare
|
I tried it against three instances: with 0.5.1, I got:
with this change, I got:
|
This makes me think that those servers aren't unquoting the param before parsing it as JSON. Per #362 (comment) this is technically a bug, but since
this makes me think we shouldn't url-quote the param here or in #362. @philvarner thoughts? |
|
Closing as OBE (#362 (comment)). |
Related Issue(s):
Description:
The stringified intersects dictionary was being double-stringified. This fix uses urllib.parse.quote_plus to urlencode the intersects string for GET requests.
Includes:
This fix proved hard to test using the existing procedures, because stac-fastapi does not support intersects for GET requests: stac-utils/stac-fastapi#468.
PR Checklist: