fix: UID SEARCH on an empty mailbox must match nothing, not answer NO#478
Open
akeemjenkins wants to merge 1 commit into
Open
fix: UID SEARCH on an empty mailbox must match nothing, not answer NO#478akeemjenkins wants to merge 1 commit into
akeemjenkins wants to merge 1 commit into
Conversation
RFC 3501 section 6.4.8: "A non-existent unique identifier is ignored without any error message generated." In an empty mailbox every UID is non-existent, so a UID search key matches nothing. resolveUIDInterval instead reported ErrNoSuchMessage from resolveUID's empty-snapshot guard, so e.g. 'UID SEARCH UID 1' against an empty mailbox answered 'NO no such message' rather than an empty untagged SEARCH plus OK. Non-existent UIDs in a non-empty mailbox were already ignored without error, and the FETCH/STORE/COPY range path got an equivalent empty-mailbox guard in b04fb94 (GODT-2218); the SEARCH path calls resolveUIDInterval directly and was missed. Clients that verify their own mutations hit this whenever a MOVE drains a mailbox: the verification search for the moved UIDs fails exactly when the move fully succeeded.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A SEARCH whose criteria reference UIDs answers
NO no such messagewhen the selected mailbox is empty:RFC 3501 §6.4.8 requires the opposite:
In an empty mailbox every UID is non-existent, so a
UID <sequence set>search key matches nothing — the correct answer is an empty untagged* SEARCHplus taggedOK. Gluon already behaves this way for non-existent UIDs in a non-empty mailbox (they resolve and simply match nothing), so the empty-mailboxNOis also internally inconsistent.Root cause
buildSearchOpUIDcallssnap.resolveUIDInterval, whoseresolveUIDerrors withErrNoSuchMessagewhenever the snapshot holds zero messages. The equivalent FETCH/STORE/COPY range path got an empty-mailbox guard back in b04fb94 (GODT-2218) — "If there are no messages in the mailbox, we still resolve without error" — but the SEARCH path callsresolveUIDIntervaldirectly and was missed.Impact
Any client that verifies its own mutations trips over this precisely when the mutation fully succeeds: after a MOVE that drains a mailbox, a verification
UID SEARCH UID <moved set>against the now-empty source fails, reading as "move not applied" when the empty mailbox is exactly the expected outcome. Observed in practice through Proton Mail Bridge 3.25.0.Fix
resolveUIDIntervalreturns no intervals for an empty snapshot (mirroring the GODT-2218 guard), so UID search keys match nothing instead of erroring. This also coversUID SEARCH UID 1:*on an empty mailbox. Sequence-number resolution is unchanged.Added
TestSearchUIDEmptyMailboxcoveringuid search uid 1,search uid 1,3:5, anduid search uid 1:*against an empty INBOX; it fails withNO no such messagebefore the fix.go test ./tests ./internal/statepasses.