duesee / imap-codec

Rock-solid and complete codec for IMAP
Apache License 2.0
39 stars 14 forks source link

`ValidationError` & `ValidationErrorKind::Invalid` is useless without information of what the invalid value and what type was expected #606

Open epilys opened 4 hours ago

epilys commented 4 hours ago

ValidationError & ValidationErrorKind::Invalid is useless without information of what the invalid value and what type was expected.

Both types derive traits which would break if we added extra information:

https://github.com/duesee/imap-codec/blob/086523d64095fd7da35b4fe5ffe27067185c9801/imap-types/src/error.rs#L9-L13

But is a validation error really equal to another validation error if the value domain and/or the value are different? 🤔 Do these errors need to be hashable/orderable/comparable?

epilys commented 4 hours ago

These are the server/client transactions intermixed with error/trace logs that prompted this post, for posterity:

S: * 1 FETCH (UID 246 MODSEQ (9563485) FLAGS (\\Deleted))\r\n
Mon, 21 Oct 2024 02:28 [DEBUG]: melib::imap::untagged: fetch uid 246 (Flag(TRASHED), [])
Mon, 21 Oct 2024 02:28 [TRACE]: melib::imap::connection: ImapType::new sent: M62 ExpungeUid { sequence_set: SequenceSet([Single(Value(246))]+) }
C: M62 UID EXPUNGE 246\r\n
S: * 1 EXPUNGE\r\n
S: * 0 EXISTS\r\n
S: M62 OK Success\r\n
Mon, 21 Oct 2024 02:28 [TRACE]: meli: "IMAP transaction validation failed\nCaused by:\n[2] Validation failed: Invalid value"