Skip to content

fix(activesync): return object-not-found for deleted ItemOperations f…#47

Open
TDannhauer wants to merge 1 commit into
FRAMEWORK_6_0from
fix/find_result_itemOperation
Open

fix(activesync): return object-not-found for deleted ItemOperations f…#47
TDannhauer wants to merge 1 commit into
FRAMEWORK_6_0from
fix/find_result_itemOperation

Conversation

@TDannhauer

Copy link
Copy Markdown
Contributor

fix(activesync): return object-not-found for deleted ItemOperations fetches

Summary

Fix ItemOperations:Fetch for mailbox messages so deleted or missing items return ItemOperations status 6 (Object not found) instead of propagating Horde_Exception_NotFound as an HTTP 500.

This was observed when using EAS 16.0 Find on iOS: search hits could be opened successfully, but after deleting messages from the search results view the client issued follow-up ItemOperations fetches for stale IDs. The server logged Nicht gefunden and returned HTTP 500.

Problem

For mailbox ItemOperations:Fetch requests identified by FolderId/ServerEntryId or SearchLongId, the handler:

  1. Emitted status 1 (Success) before attempting the fetch
  2. Wrote folder metadata (FolderId, ServerEntryId, FolderType) before verifying the message exists
  3. Did not catch Horde_Exception_NotFound from fetch() / getMessage()

When a message had been deleted after appearing in Find results, the exception bubbled up and Horde returned HTTP 500 while the device log showed a contradictory success status followed by ERR: Nicht gefunden.

A related case involved virtual Find folder IDs (M<uid> from iOS unified search): when resolveLongIdForUid() could not locate the message, the code fell through to getBackendIdForFolderUid('M…'), which raised Horde_ActiveSync_Exception_FolderGone and produced a server error instead of a clean per-fetch not-found response.

Solution

  • Add STATUS_OBJECTNOTFOUND = 6 per MS-ASCMD ItemOperations status codes
  • Introduce _fetchMailboxMessage() to centralize mailbox fetch logic with proper exception handling
  • Fetch first, then emit status and metadata only on success
  • Map Horde_Exception_NotFound → status 6, log at INFO, skip properties encoding
  • Map unresolved virtual M<uid> folder fetches → status 6 instead of folder-gone server error
  • Reset _statusCode per mailbox fetch iteration (important when multiple fetches are batched)

Changes

lib/Horde/ActiveSync/Request/ItemOperations.php

Change Detail
STATUS_OBJECTNOTFOUND New constant (6)
_fetchMailboxMessage() Shared fetch helper for searchlongid and folderid/serverentryid paths
Fetch ordering Status and folder tags emitted only after a successful fetch
Error handling Horde_Exception_NotFound → status 6; Horde_ActiveSync_Exception_FolderGone → status 3
Virtual folder fallback M<uid> folders with no resolvable long id → status 6

Unchanged: attachment (FileReference) and document library fetch paths.

Test plan

  • EAS 16.0 Find on iOS returns search hits
  • Open a search result → message loads via ItemOperations:Fetch (status 1)
  • Delete a message from the search results view → subsequent ItemOperations:Fetch returns status 6, no HTTP 500
  • horde.log shows INFO ItemOperations fetch: message not found …, not Returning HTTP 500
  • Device log shows per-fetch status 6 for stale hits, not ERR: Nicht gefunden
  • Normal (non-search) ItemOperations:Fetch for existing messages still works
  • php -l on modified file passes

Related

Complements EAS 16.0 Find support, where Find.php already skips stale hits during result encoding. This change covers the separate client path where iOS re-fetches individual messages via ItemOperations after search.

Commit message

fix(activesync): return object-not-found for deleted ItemOperations fetches

Catch Horde_Exception_NotFound when opening search hits that were removed
after Find, and respond with ItemOperations status 6 instead of HTTP 500.
Fetch mailbox messages before emitting success status and folder metadata.

…etches

Catch Horde_Exception_NotFound when opening search hits that were removed
after Find, and respond with ItemOperations status 6 instead of HTTP 500.
Fetch mailbox messages before emitting success status and folder metadata.
@TDannhauer TDannhauer requested a review from ralflang June 10, 2026 20:11
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