fix(client): URL encoding bug #1
Open
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.
Description
Fixes meilisearch#511, although with a nuance. The bug in meilisearch#511 (root cause analysis for reference) is already fixed from a user-perspective. Not because the Meilisearch SDK explicitly encodes URLs, but because reqwest (the HTTP client) appears to automatically encode URLs when they're passed to it.
Changes:
src/indexes.rs
Bug Description
This bug relates to a problem where documents with single quotes in their primary key field silently failed to be added to the Meilisearch index due to improper URL handling in the Rust SDK. Specifically, the primary key parameter was directly interpolated into the URL without URL encoding, causing malformed URLs when special characters were present.
Steps to Reproduce
cargo test -- tests::index_primary_key_test_version_check::test_reqwest_handles_url_encoding --nocapture
Expected vs Actual Behavior
Expected Behavior (based on RCA)
Actual Behavior
Important Findings
src/indexes.rs
still directly interpolates the primary key parameter without encoding:This explains why the code appears to still have the bug (no explicit encoding) but actually works correctly (thanks to reqwest's automatic URL encoding).
Other changes
NA
Tested
Root cause: https://hyperdrive.engineering/#report-49eaa957-fe2c-44f4-a9f0-76507540bd54
Related issues
index.add_document
call. meilisearch/meilisearch-rust#511Backwards compatibility
Yes.
Documentation
NA