meilisearch / meilisearch-rust

Rust wrapper for the Meilisearch API.

Home Page:https://www.meilisearch.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error when parsing error status on index creation

irevoire opened this issue · comments

commented

Hi, @irevoire . I run your example, but it didn't fail. Although, I've narrowed down where the error comes from in my case.

I mistakenly thought that it was coming from when setting the settings, but it's in fact coming when creating the index (client.create_index), specifically when parsing the response body:

fn parse_response<Output: DeserializeOwned>(
    status_code: u16,
    expected_status_code: u16,
    body: String,
) -> Result<Output, Error> {
    if status_code == expected_status_code {
        match from_str::<Output>(&body) {
            Ok(output) => {
                trace!("Request succeed");
                return Ok(output);
            }
            Err(e) => {
                error!("Request succeeded but failed to parse response");
                return Err(Error::ParseError(e));
            }
        };

I can see in the console "Request succeeded but failed to parse response" right before the parse error.

I will ignore the error and add the settings anyway. If I can further reduce the scope of the error, will let you know.

Originally posted by @moy2010 in #230 (comment)

commented

@moy2010 I tried to reproduce your issue but did not succeed 😔
I added two tests to the SDK to ensure we can parse the errors meilisearch returns on an index creation, but I encountered no issue, so I don't know how to help.

Also, just to be sure, are you using meilisearch v0.25.2? Maybe it's an issue with the v0.25.0/1? 🤔

If you find more information, please tell me, but for now, since I can't reproduce, I'll stop working on it 😔

Yup, v0.25.2 with the Rust client 0.15 :(

But no worries, @irevoire. This is not hindering me :). Thanks for putting some time into the investigation!

An update on this:

After upgrading my Actix web server to v4.0.1 and the rest of the ecosystem (Tokio, Reqwest, etc.), the errors went away. I'm suspecting that some transitive dependency from the Meilisearch package was resolving to the older version that I was depending on, and this was causing the payload parsing issues being returned by the SDK.

commented

Oh good to hear, closing then!
Thanks for the feedback ❤️