Skip to content

fix(activesync): skip missing messages in Find results#46

Open
TDannhauer wants to merge 1 commit into
FRAMEWORK_6_0from
fix/FIND_skip-nonexistent_messages
Open

fix(activesync): skip missing messages in Find results#46
TDannhauer wants to merge 1 commit into
FRAMEWORK_6_0from
fix/FIND_skip-nonexistent_messages

Conversation

@TDannhauer

Copy link
Copy Markdown
Contributor

Skip missing messages in Find results

Summary

Prevents a single unavailable mailbox hit from failing the entire EAS 16.0 Find response with HTTP 500.

Problem

Find searches IMAP and then fetches each hit via itemOperationsFetchMailbox() to build preview properties (Subject, From, Preview, etc.). If one message is no longer available when fetched — deleted, moved, or present only in a stale search cache entry — getMessage() throws Horde_Exception_NotFound (Nicht gefunden). That exception propagated out of _encodeResult() and aborted the whole Find response, even when other hits were valid.

Observed in production: two ESET messages encoded successfully; a third stale UID caused HTTP 500 and a truncated WBXML buffer.

Solution

  • Fetch the message before opening the Find:Result WBXML element.
  • Catch Horde_Exception_NotFound, log at info level, and skip that hit.
  • Return a boolean from _encodeResult(); only successfully encoded hits count toward Find:Range.

Find:Total still reflects the IMAP search count; Find:Range reflects the number of results actually returned.

Files changed

  • lib/Horde/ActiveSync/Request/Find.php

Test plan

  • Search for a term with known matches — results return status 1, no HTTP 500
  • If reproducible: delete/move a message that matches the query, search again — remaining hits still returned; log contains Find: message … no longer available, skipping result.
  • Find:Range matches the number of encoded results when some hits are skipped

Suggested commit message

fix(activesync): skip missing messages in Find results

Fetch each hit before encoding and ignore Horde_Exception_NotFound
so a deleted or stale search result no longer aborts the entire
Find response with HTTP 500.

Author

Torben Dannhauer torben@dannhauer.de

Fetch each hit before encoding and ignore Horde_Exception_NotFound
so a deleted or stale search result no longer aborts the entire
Find response with HTTP 500.
@TDannhauer TDannhauer requested a review from ralflang June 10, 2026 19:45
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

Successfully merging this pull request may close these issues.

1 participant