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

Fix bug for encoding filter_properties query parameter. #402

Merged
merged 1 commit into from
May 2, 2023

Conversation

parulbaweja
Copy link
Contributor

@parulbaweja parulbaweja commented Apr 27, 2023

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:

  • an ID U:C< was returned in the notion.databases.retrieve() call as U%3AC%3C (in the JS SDK)
  • U%3AC%3C is passed to notion.databases.query() (the JS SDK) which was getting encoded once again to U%253AC%253C
  • The Notion server looked for 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 to fetch, so that fetch 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, like page_size for retrieving a page property item are not impacted (I tested retrieve page property item with this change ✅ )

@parulbaweja parulbaweja force-pushed the parul--filter-properties-decode-encode branch 2 times, most recently from 39a3656 to 5be2877 Compare April 27, 2023 22:05
@parulbaweja parulbaweja force-pushed the parul--filter-properties-decode-encode branch from 5be2877 to 7dfc885 Compare April 28, 2023 17:27
@parulbaweja parulbaweja requested review from rhart92, s-h-a-r-c and a team April 28, 2023 19:24
@parulbaweja parulbaweja merged commit 0a385a0 into main May 2, 2023
@parulbaweja parulbaweja deleted the parul--filter-properties-decode-encode branch May 2, 2023 16:55
rhart92 pushed a commit that referenced this pull request Oct 3, 2023
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 this pull request may close these issues.

2 participants