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

Simple LIST command fails with Gmail #80

Closed
theduke opened this issue Jul 16, 2018 · 3 comments
Closed

Simple LIST command fails with Gmail #80

theduke opened this issue Jul 16, 2018 · 3 comments

Comments

@theduke
Copy link

theduke commented Jul 16, 2018

Hey there.

I'm trying to LIST all mailboxes with Gmail.

Connecting works fine, but executing the list command results in weird "Unknown command" errors.

NOTE: the value for the command changes with each invocation.

 INFO 2018-07-16T14:19:51Z: mycloudbackup::service::email: listing mailboxes...
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: BadResponse("Unknown command q4-v6mb43737048lth")

stack backtrace:
   0:     0x55ab9a875425 - backtrace::backtrace::libunwind::trace::hf612167c3b0ad921
                        at /home/theduke/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.9/src/backtrace/libunwind.rs:53
                         - backtrace::backtrace::trace::h574c6ad167c02b7c
                        at /home/theduke/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.9/src/backtrace/mod.rs:42
   1:     0x55ab9a870c5e - backtrace::capture::Backtrace::new_unresolved::hfc2f37046d10e114
                        at /home/theduke/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.9/src/capture.rs:88
   2:     0x55ab9a86f037 - failure::backtrace::internal::InternalBacktrace::new::h50a420eea00b0a25
                        at /home/theduke/.cargo/registry/src/github.com-1ecc6299db9ec823/failure-0.1.1/src/backtrace/internal.rs:44
   3:     0x55ab9a86e7dc - failure::backtrace::Backtrace::new::ha4994e8172e6037b
                        at /home/theduke/.cargo/registry/src/github.com-1ecc6299db9ec823/failure-0.1.1/src/backtrace/mod.rs:98
   4:     0x55ab9a6e4d4d - <failure::error::Error as core::convert::From<F>>::from::h2008397b91b24e51
                        at /home/theduke/.cargo/registry/src/github.com-1ecc6299db9ec823/failure-0.1.1/src/error.rs:34
   5:     0x55ab9a6e4852 - mycloudbackup::service::email::EmailService::run::h09ca1ab1e24544f2
                        at src/service/email/mod.rs:40
   6:     0x55ab9a6e6a3e - mycloudbackup::main::h1b5295b517f21400
                        at src/main.rs:30
   7:     0x55ab9a6e3e7f - std::rt::lang_start::{{closure}}::hf04d67d357e8192d
                        at /checkout/src/libstd/rt.rs:74
   8:     0x55ab9a95a2e2 - std::rt::lang_start_internal::{{closure}}::h72602870b4a34363
                        at libstd/rt.rs:59
                         - std::panicking::try::do_call::hc2917ab2c572e22d
                        at libstd/panicking.rs:310
   9:     0x55ab9a973239 - __rust_maybe_catch_panic
                        at libpanic_unwind/lib.rs:105
  10:     0x55ab9a95f4f5 - std::panicking::try::h3777f1f99a655493
                        at libstd/panicking.rs:289
                         - std::panic::catch_unwind::hab6d1467193fc938
                        at libstd/panic.rs:374
                         - std::rt::lang_start_internal::h106bcdfb2e3beaf8
                        at libstd/rt.rs:58
  11:     0x55ab9a6e3e57 - std::rt::lang_start::hfacb80090f7d05a5
                        at /checkout/src/libstd/rt.rs:74
  12:     0x55ab9a6e6adc - main
  13:     0x7fa1a55b306a - __libc_start_main
  14:     0x55ab9a6dc369 - _start
  15:                0x0 - <unknown>', libcore/result.rs:945:5
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at libstd/sys_common/backtrace.rs:71
             at libstd/sys_common/backtrace.rs:59
   2: std::panicking::default_hook::{{closure}}
             at libstd/panicking.rs:211
   3: std::panicking::default_hook
             at libstd/panicking.rs:227
   4: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:463
   5: std::panicking::begin_panic_fmt
             at libstd/panicking.rs:350
   6: rust_begin_unwind
             at libstd/panicking.rs:328
   7: core::panicking::panic_fmt
             at libcore/panicking.rs:71
   8: core::result::unwrap_failed
             at /checkout/src/libcore/macros.rs:26
   9: <core::result::Result<T, E>>::unwrap
             at /checkout/src/libcore/result.rs:782
  10: mycloudbackup::main
             at src/main.rs:30
  11: std::rt::lang_start::{{closure}}
             at /checkout/src/libstd/rt.rs:74
  12: std::panicking::try::do_call
             at libstd/rt.rs:59
             at libstd/panicking.rs:310
  13: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:105
  14: std::rt::lang_start_internal
             at libstd/panicking.rs:289
             at libstd/panic.rs:374
             at libstd/rt.rs:58
  15: std::rt::lang_start
             at /checkout/src/libstd/rt.rs:74
  16: main
  17: __libc_start_main
  18: _start
        let ssl_connector = TlsConnector::builder()?.build()?;
        let socket_addr = (conf.domain.as_str(), conf.socket);
        let mut imap = Client::secure_connect(socket_addr, &conf.domain, &ssl_connector)?;

        // List all folders.
        info!("listing mailboxes...");
        let folders = imap.list("", "*")?;
        println!("{:#?}", folders);
@theduke
Copy link
Author

theduke commented Jul 16, 2018

Turns out I forgot to call client.login(...).

Is there a smoother way to detect a missing login and produce an approrpiate error?

@jonhoo
Copy link
Collaborator

jonhoo commented Jul 16, 2018

Hmm, yes, in theory we could differentiate this using types. We could give you an UnauthenticatedClient when you call connect (or secure_connect), and then have login consume self and produce a Client. It'd be a pretty major API change, but I have some other changes along those lines I've wanted to make too, so I think it's a good idea. I'm sort of waiting on #69, since without that I have relatively little agency in publishing changes :)

@dario23
Copy link

dario23 commented Jul 29, 2018

@jonhoo +1 for the UnauthenticatedClient/Client idea, i had a small step in that direction too, some time ago

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

3 participants