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

Empty envelope search result leads to page 1 out of bounds error #535

Open
echo-bravo-yahoo opened this issue Jan 6, 2025 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@echo-bravo-yahoo
Copy link

Hey - I'm using himalaya with gmail, and am trying to find unread emails in a folder. If there are any unread emails, it works great - but if there are 0, it fails with the error 0: cannot list imap envelopes: page 1 out of bounds. The CLI command looks like the below; let me know if trace logs would be more useful than debug logs.

> himalaya envelope list -f "Jobs" --page-size 10 --debug not flag Seen
2025-01-06T22:06:00.181990Z  INFO himalaya::email::envelope::command::list: executing list envelopes command
2025-01-06T22:06:00.182062Z DEBUG email::imap: building 1 IMAP clients
2025-01-06T22:06:00.194431Z DEBUG client::build: rustls::client::hs: No cached session for DnsName("imap.gmail.com")
2025-01-06T22:06:00.194681Z DEBUG client::build: rustls::client::hs: Not resuming any session
2025-01-06T22:06:00.199441Z DEBUG client::build: rustls::webpki::anchors: add_parsable_certificates processed 141 valid and 0 invalid certs
2025-01-06T22:06:00.199495Z DEBUG client::build: rustls_platform_verifier::verification::others: Loaded 141 CA certificates from the system
2025-01-06T22:06:00.210875Z DEBUG client::build: rustls::client::hs: Using ciphersuite TLS13_AES_256_GCM_SHA384
2025-01-06T22:06:00.210899Z DEBUG client::build: rustls::client::tls13: Not resuming
2025-01-06T22:06:00.211160Z DEBUG client::build: rustls::client::tls13: TLS1.3 encrypted extensions: []
2025-01-06T22:06:00.211176Z DEBUG client::build: rustls::client::hs: ALPN protocol is None
2025-01-06T22:06:00.330135Z DEBUG client::build: email::imap: using password authentication
2025-01-06T22:06:00.330172Z DEBUG client::build: email::imap: supported auth mechanisms mechanisms=[XOAuth2, Plain, Other(AuthMechanismOther(Atom("PLAIN-CLIENTTOKEN"))), OAuthBearer]
2025-01-06T22:06:00.330198Z DEBUG client::build: email::imap: trying auth mechanism… mechanism=XOAuth2
2025-01-06T22:06:00.330210Z DEBUG client::build: email::imap: trying auth mechanism… mechanism=Plain
2025-01-06T22:06:02.015438Z DEBUG client::build: email::imap: authentication succeeded! mechanism=Plain
2025-01-06T22:06:02.015607Z  INFO email::email::envelope::list::imap: listing IMAP envelopes from mailbox Jobs
2025-01-06T22:06:02.015624Z DEBUG email::imap: client 1/1 is free, locking it
2025-01-06T22:06:02.015637Z DEBUG email::email::envelope::list::imap: UTF7-encoded mailbox name="Jobs"
2025-01-06T22:06:02.253922Z  WARN select_mailbox{client=1}: imap_codec::response: Rectified missing `text` to "..."
2025-01-06T22:06:02.253944Z  WARN select_mailbox{client=1}: imap_client::tasks::resolver: received unsolicited unsolicited=Status(Untagged(StatusBody { kind: Ok, code: Some(Other(CodeOther(b"HIGHESTMODSEQ 17352329"))), text: Text("...") }))
2025-01-06T22:06:02.253980Z  WARN select_mailbox{client=1}: imap_client::tasks::tasks::select: missing required UNSEEN OK untagged response
2025-01-06T22:06:02.254011Z DEBUG email::email::envelope::list::imap: mailbox selected name="Jobs" data=SelectDataUnvalidated { flags: Some([Answered, Flagged, Draft, Deleted, Seen, Keyword(Atom("$Forwarded")), Keyword(Atom("$NotPhishing")), Keyword(Atom("$Phishing"))]), exists: Some(589), recent: Some(0), unseen: None, permanent_flags: Some([Flag(Answered), Flag(Flagged), Flag(Draft), Flag(Deleted), Flag(Seen), Flag(Keyword(Atom("$Forwarded"))), Flag(Keyword(Atom("$NotPhishing"))), Flag(Keyword(Atom("$Phishing"))), Asterisk]), uid_next: Some(632), uid_validity: Some(65) }
2025-01-06T22:06:02.418131Z DEBUG email::email::envelope::list::imap: fetching envelopes using 0 chunks uids=[]
Error:
   0: cannot list imap envelopes: page 1 out of bounds

Location:
   /home/pi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pimalaya-tui-0.2.1/src/himalaya/backend.rs:513

Note: Run with --trace to enable verbose logs with backtrace.

Looking at the (possibly related) #518, I also tried with an explicitly 0 page size:

> himalaya envelope list -f "Jobs" --page-size 0 --debug not flag Seen
2025-01-06T22:07:19.209749Z  INFO himalaya::email::envelope::command::list: executing list envelopes command
2025-01-06T22:07:19.209841Z DEBUG email::imap: building 1 IMAP clients
2025-01-06T22:07:19.228840Z DEBUG client::build: rustls::client::hs: No cached session for DnsName("imap.gmail.com")
2025-01-06T22:07:19.229006Z DEBUG client::build: rustls::client::hs: Not resuming any session
2025-01-06T22:07:19.234467Z DEBUG client::build: rustls::webpki::anchors: add_parsable_certificates processed 141 valid and 0 invalid certs
2025-01-06T22:07:19.234499Z DEBUG client::build: rustls_platform_verifier::verification::others: Loaded 141 CA certificates from the system
2025-01-06T22:07:19.246783Z DEBUG client::build: rustls::client::hs: Using ciphersuite TLS13_AES_256_GCM_SHA384
2025-01-06T22:07:19.246813Z DEBUG client::build: rustls::client::tls13: Not resuming
2025-01-06T22:07:19.247154Z DEBUG client::build: rustls::client::tls13: TLS1.3 encrypted extensions: []
2025-01-06T22:07:19.247172Z DEBUG client::build: rustls::client::hs: ALPN protocol is None
2025-01-06T22:07:19.358557Z DEBUG client::build: email::imap: using password authentication
2025-01-06T22:07:19.358592Z DEBUG client::build: email::imap: supported auth mechanisms mechanisms=[XOAuth2, Plain, Other(AuthMechanismOther(Atom("PLAIN-CLIENTTOKEN"))), OAuthBearer]
2025-01-06T22:07:19.358618Z DEBUG client::build: email::imap: trying auth mechanism… mechanism=XOAuth2
2025-01-06T22:07:19.358631Z DEBUG client::build: email::imap: trying auth mechanism… mechanism=Plain
2025-01-06T22:07:19.801078Z DEBUG client::build: email::imap: authentication succeeded! mechanism=Plain
2025-01-06T22:07:19.801244Z  INFO email::email::envelope::list::imap: listing IMAP envelopes from mailbox Jobs
2025-01-06T22:07:19.801264Z DEBUG email::imap: client 1/1 is free, locking it
2025-01-06T22:07:19.801276Z DEBUG email::email::envelope::list::imap: UTF7-encoded mailbox name="Jobs"
2025-01-06T22:07:20.011839Z  WARN select_mailbox{client=1}: imap_codec::response: Rectified missing `text` to "..."
2025-01-06T22:07:20.011873Z  WARN select_mailbox{client=1}: imap_client::tasks::resolver: received unsolicited unsolicited=Status(Untagged(StatusBody { kind: Ok, code: Some(Other(CodeOther(b"HIGHESTMODSEQ 17352329"))), text: Text("...") }))
2025-01-06T22:07:20.011914Z  WARN select_mailbox{client=1}: imap_client::tasks::tasks::select: missing required UNSEEN OK untagged response
2025-01-06T22:07:20.011936Z DEBUG email::email::envelope::list::imap: mailbox selected name="Jobs" data=SelectDataUnvalidated { flags: Some([Answered, Flagged, Draft, Deleted, Seen, Keyword(Atom("$Forwarded")), Keyword(Atom("$NotPhishing")), Keyword(Atom("$Phishing"))]), exists: Some(589), recent: Some(0), unseen: None, permanent_flags: Some([Flag(Answered), Flag(Flagged), Flag(Draft), Flag(Deleted), Flag(Seen), Flag(Keyword(Atom("$Forwarded"))), Flag(Keyword(Atom("$NotPhishing"))), Flag(Keyword(Atom("$Phishing"))), Asterisk]), uid_next: Some(632), uid_validity: Some(65) }
2025-01-06T22:07:20.177568Z DEBUG email::email::envelope::list::imap: fetching envelopes using 0 chunks uids=[]
Error:
   0: cannot list imap envelopes: page 1 out of bounds

Location:
   /home/pi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pimalaya-tui-0.2.1/src/himalaya/backend.rs:513

Note: Run with --trace to enable verbose logs with backtrace.
@soywod
Copy link
Member

soywod commented Jan 8, 2025

Indeed, nice catch! It should return an empty table instead. I will fix this for the next patch release.

@soywod soywod added the bug Something isn't working label Jan 8, 2025
@soywod soywod added this to Pimalaya Jan 8, 2025
@soywod soywod moved this to Todo in Pimalaya Jan 8, 2025
@soywod soywod self-assigned this Jan 8, 2025
@soywod soywod changed the title Empty queries fail ("cannot list imap envelopes: page 1 out of bounds") Empty envelope search result leads to page 1 out of bounds error Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Todo
Development

No branches or pull requests

2 participants