Fix bug for encoding filter_properties query parameter. #402
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.
Problem:
filter_properties
is a query parameter, which gets URI encoded when a request is made with the JS SDK. A bug report came in that when querying for a specific property in the Query Database endpoint, an error was occurring stating that the collection schema was invalid.When you retrieve a database, the response already includes URI-encoded IDs for properties. This problem occurred because our JS SDK was further encoding the ID. For example:
U:C<
was returned in thenotion.databases.retrieve()
call asU%3AC%3C
(in the JS SDK)U%3AC%3C
is passed tonotion.databases.query()
(the JS SDK) which was getting encoded once again toU%253AC%253C
U%253AC%253C
but couldn't find it & returned an error.This PR fixes the JS SDK to not further encode an already encoded
filter_properties
query param ID. In this PR, we take the approach of decoding, passing the URL tofetch
, so thatfetch
can encode subsequently. This complements Notion API's handling as well, so that a developer can copy/paste or include a property ID directly in a URL.Note: this is isolated to endpoints that have query parameters with array types (currently, this is only
filter_properties
). Other query parameters, likepage_size
for retrieving a page property item are not impacted (I tested retrieve page property item with this change ✅ )