Skip to content

Commit 1282e77

Browse files
committed
Do not panic when mailboxId is not found (closes #1293)
1 parent d4ac752 commit 1282e77

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

crates/imap/src/op/list.rs

+17-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use imap_proto::{
2222
},
2323
receiver::Request,
2424
};
25+
use trc::StoreEvent;
2526

2627
use super::ImapContext;
2728

@@ -202,7 +203,22 @@ impl<T: SessionStream> SessionData<T> {
202203

203204
for (mailbox_name, mailbox_id) in &account.mailbox_names {
204205
if matches_pattern(&patterns, mailbox_name) {
205-
let mailbox = account.mailbox_state.get(mailbox_id).unwrap();
206+
let mailbox = if let Some(mailbox) = account.mailbox_state.get(mailbox_id) {
207+
mailbox
208+
} else {
209+
trc::event!(
210+
Store(StoreEvent::UnexpectedError),
211+
Details = "IMAP mailbox no longer present in account state",
212+
Id = *mailbox_id,
213+
Details = account
214+
.mailbox_state
215+
.keys()
216+
.copied()
217+
.map(trc::Value::from)
218+
.collect::<Vec<_>>()
219+
);
220+
continue;
221+
};
206222
let mut has_recursive_match = false;
207223
if recursive_match {
208224
let prefix = format!("{}/", mailbox_name);

0 commit comments

Comments
 (0)