From e1da535dc238fdbbf39c4a5e0aa66245f3b4f61b Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Sat, 5 Apr 2025 17:03:01 -0500 Subject: [PATCH] meilisearch: Trim whitespace from token When reading the Meilisearch token from the file specified in the configuration, we need to ensure any whitespace are trimmed from the string. If the token file was created with a text editor, or even a shell pipeline, it's likely to have a trailing newline character. If we do not remove this, authenticated requests to Meilisearch will fail. --- src/meilisearch.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/meilisearch.rs b/src/meilisearch.rs index 8dff994..27527cc 100644 --- a/src/meilisearch.rs +++ b/src/meilisearch.rs @@ -20,7 +20,7 @@ impl TryFrom<&Config> for Client { Some(t) => Some(std::fs::read_to_string(t).map_err(Error::Token)?), None => None, }; - Ok(Client::new(&config.meilisearch.url, token)?) + Ok(Client::new(&config.meilisearch.url, token.as_deref().map(str::trim))?) } }