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

Fetching a body section fails with "incomplete data, need minimum X bytes" #71

Open
t348575 opened this issue Mar 24, 2023 · 2 comments

Comments

@t348575
Copy link

t348575 commented Mar 24, 2023

Running any of these:
(with any valid uid)

let mails: Vec<_> = session.uid_fetch("22213", "BODY.PEEK[1]").await?.try_collect().await?;
let mails: Vec<_> = session.uid_fetch("22213", "BODY[1]").await?.try_collect().await?;

causes no body, text or any other data to be parsed, and the trace shows it hitting this:

Err(nom::Err::Incomplete(Needed::Size(min))) => {

The need minimum X bytes is always a little lower than the size of the data returned. In this case 220 bytes returned, but it says minimum 130.

Run with gmail imap servers, with this crate setup:

async-imap = { version = "0.6.0", default-features = false, features = ["runtime-tokio"] }

calling BODY[] or BODY.PEEK[] or any other call works fine.

Connecting to the imap server directly like so:

openssl s_client -connect imap.gmail.com:993 -crlf

and running the same commands (with same UIDs) seems to work fine.

@link2xt
Copy link
Contributor

link2xt commented Mar 25, 2023

Does it only happen with this particular message (UID=22213) or with any messages? Could you extract the input and try to turn it into an imap-proto test, e.g. try inserting it somewhere here: https://github.com/djc/tokio-imap/blob/ae6e3437eacf21340bca9d00ae8e9f16509bb572/imap-proto/src/parser/tests.rs

What is the version of imap-proto in the lockfile?

@t348575
Copy link
Author

t348575 commented Mar 25, 2023

imap-proto is 0.16.2 in the lockfile. I tried plugging it into a test there and it returned an error (i directly copy pasted the email from the terminal, so this might have caused some CRLF to disappear). The email used was the notification email i got from github for your reply above.

This happens to any UID email.

#[test]
fn my_test() {
    let lines = b"* 20763 FETCH (BODY[1] {506}\r\n
Does it only happen with this particular message or with any messages? Could you extract the input and try to turn it into an `imap-proto` test, e.g. try inserting it somewhere here: https://github.com/jonhoo/rust-imap/blob/main/src/parse.rs

--
Reply to this email directly or view it on GitHub:
https://github.com/async-email/async-imap/issues/71#issuecomment-1483830410
You are receiving this because you authored the thread.

Message ID: <async-email/async-imap/issues/71/[email protected]>)
A008 OK Success\r\n
";
    println!("{:#?}", parse_response(lines));
}

The above returns an Err with the bytes and code: TakeWhile1

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

No branches or pull requests

2 participants