stalwartlabs / jmap-client

JMAP client library for Rust
Apache License 2.0
62 stars 8 forks source link

data did not match any variant of untagged enum SingleMethodResponse #5

Closed arlyon closed 1 year ago

arlyon commented 1 year ago

Hi!

First of all, wow! This library is exceptional. I am trying to forego paying for sendgrid and using this to send emails via fastmail. I am running into an issue.

    let mailbox_id = client.mailbox_get("REDACTED", None::<Vec<Property>>).await.unwrap().unwrap().take_id();

    // Import a message into the mailbox.
    client
    .email_import(
        b"From: user@myemail.com\r\nSubject: test\r\n\r\n test".to_vec(),
        [&mailbox_id],
        ["$draft"].into(),
        None,
    )
    .await
    .unwrap();

I have found (through some logging) that the return data is as follows:

{"methodResponses":[["Email/import",{"notCreated":{},"accountId":"ID","created":{"i0":{"threadId":"ID","blobId":"G5211ba6f6add5bb3dfffa67ba0f045b5fe468e30","size":46,"id":"ID"}}},"s0"]],"latestClientVersion":"","sessionState":"ID"}

However, I am unable to actually get the message:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Parse(Error("data did not match any variant of untagged enum SingleMethodResponse", line: 1, column: 230))', src/main.rs:92:6

It seems that jmap-client::core::request is unable to cast the return type to a SingleMethodResponse. Any thoughts? It seems that fastmail does not return newState and so the untagged enum parsing fails.

arlyon commented 1 year ago

I have opened a support ticket with fastmail about this, as I believe this library is correct (https://jmap.io/spec-mail.html#emailimport)

mdecimus commented 1 year ago

Hi,

I agree, it looks like the newState field is missing and, according to the JMAP standard, this is a required field. You can also report this issue on the Fastmail API topicbox which goes directly to the Fastmail developers.

arlyon commented 1 year ago

I will close this for now, but update it when I get more information from fastmail. Here is the current status from their support:

Hello,

Thanks for your patience as we looked into this! I'm happy to share an update on the issue you've reported.

Our developers have identified that this is a bug at out end, but I'm afraid there is not a timeline as to when they will be able to fix this. It is contained within a list of known issues to work on, though.

If I can do anything else for you at this time, please let me know.

Regards, Vysakh