Skip to content
This repository was archived by the owner on Jan 4, 2025. It is now read-only.

Fix for double encoding of the timestamp in the params#258

Merged
Bobspadger merged 1 commit intomasterfrom
issue/257
Mar 15, 2021
Merged

Fix for double encoding of the timestamp in the params#258
Bobspadger merged 1 commit intomasterfrom
issue/257

Conversation

@Bobspadger
Copy link
Copy Markdown
Member

Fixes #257

Stops the double encoding of the text string with the clean_string() method as the .isoformat() on the datetime object returns valid string already.

By calling the clean_string() method we got a double encoded timestamp that broke the Amazon MWS calls.

This is a confirmed working fix by testing against a couple of live endpoints, and confirmed the bug existed by getting the MWS errors back.

The code that breaks the calls appears to be in Develop branch as well - I've not investigated too hard as to why the different versions give different results as this was more an emergency fix to get a working version out onto pypi.

@GriceTurrble FYI but I'm going to merge this and push out to pypi ASAP

…`.isoformat()` method returns it as a valid string and the `quote` just double encodes the values.

Tests all still pass, and this has been verified by integration testing on the products endpoint.

Version bump to 0.8.13
@Bobspadger Bobspadger requested a review from GriceTurrble March 15, 2021 11:15
@Bobspadger Bobspadger changed the base branch from develop to master March 15, 2021 11:16
@Bobspadger Bobspadger self-assigned this Mar 15, 2021
@Bobspadger Bobspadger merged commit c8fcb34 into master Mar 15, 2021
@adamantike
Copy link
Copy Markdown

@Bobspadger, not sure if you already tested with other data types, but apparently the root cause is that both clean_params_dict and calc_request_description can run clean_string.

You fixed it for dates, but if clean_value is called with a string, it will be double encoded. Maybe the correct fix is for calc_request_description to no longer encode parameters, but to expect that its input has been already encoded (using clean_params_dict).

GriceTurrble pushed a commit that referenced this pull request Jun 4, 2021
Currently, the `0.8.x` branch breaks string parameters by encoding them
twice, first in the `clean_params_dict` function, and then in
`calc_request_description`. Because of this, parameters prone to have
characters that must be escaped, like `NextToken` and URLs, do not work
correctly.

#258 was an
attempt to fix this issue, but only for timestamp fields. Strings are
still broken.

This solution is a backport of a commit
(#65) that is already present in the
`develop` branch, where the `calc_request_description` function is no
longer responsible for escaping the received parameters.

It also rollbacks
#258,
as `clean_date` must encode the received values now.
@GriceTurrble GriceTurrble deleted the issue/257 branch June 5, 2021 00:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

InvalidParameterValue error under python 3.9.2 with mws 0.8.12

3 participants