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

QueryStringParameters encoding issue #186

Closed
Cox65 opened this issue Oct 12, 2020 · 2 comments · Fixed by #187
Closed

QueryStringParameters encoding issue #186

Cox65 opened this issue Oct 12, 2020 · 2 comments · Fixed by #187

Comments

@Cox65
Copy link
Contributor

Cox65 commented Oct 12, 2020

Hi,

I suspect an issue while providing queryParameters.

When performing a query to my API using <API_ROOT>/logs?start_time=2020-10-12T14:00:00%2B02:00&end_time=2020-10-12T15:00:00%2B02:00

I get my query string values in Flask endpoint as:
start_time = "2020-10-12T14:00:00 02:00"
end_time = "2020-10-12T15:00:00 02:00"

and it should be :
start_time = "2020-10-12T14:00:00+02:00"
end_time = "2020-10-12T15:00:00+02:00"

Note: The "+" has been removed

I think this is because API Gateway is providing queryStringParameters decoded and your are not encoding them back to store them in environ["QUERY_STRING"].
If we look to what other WSGI adapters (like Zappa) are doing:

       if 'multiValueQueryStringParameters' in event_info:
            query = event_info['multiValueQueryStringParameters']
            query_string = urlencode(query, doseq=True) if query else ''
        else:
            query = event_info.get('queryStringParameters', {})
            query_string = urlencode(query) if query else ''

Hope it helps.

@adamchainz
Copy link
Owner

Thanks. I thought I got these right in #102 but it looks like that fix was incorrect. Fixed in #187 .

@adamchainz
Copy link
Owner

Fix released in 2.9.1. Thanks again for a clear bug report and sample code. If you try out apig-wsgi, let me know how it works for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants