davmail icon indicating copy to clipboard operation
davmail copied to clipboard

[Q/Advice] Dealing with empty body event

Open infpmandin opened this issue 6 months ago • 3 comments

Hello,

One of our customer (maybe using some custom application on Phone or something like that), triggered the exception related to 'empty event body'.

EwsExchangeSession: getEventContent() triggers this exception:

                    content = getItemMethod.getMimeContent();
                    if (content == null) {
                        throw new IOException("empty event body");
                    }

Which in turns generate an http not found exception

            } catch (IOException | MessagingException e) {
                throw buildHttpNotFoundException(e);
            }

From davmail.log

2025-04-25 12:25:52,523 DEBUG [CaldavConnection-49993] davmail.exchange.ExchangeSession  - Get event: <customerid_event>.EML
2025-04-25 12:25:52,663 WARN  [CaldavConnection-49993] davmail.exchange.ExchangeSession  - Unable to get event <customerid_event>.EML subject: test at null: empty event body
2025-04-25 12:25:52,663 DEBUG [CaldavConnection-49993] davmail.caldav.CaldavConnection  - status code: 404, reason phrase: Unable to get event <customerid_event>.EML subject: test creation at null: empty event body

This is puzzling me, as 404 should mean the event does not exist, not that the body is empty. Our application relies on 404 error to deal with deleted events. Maybe a different error code should be used in this case. The event exists, but I don't know if there is a problem with reading the body or not. It should be ok if it's just empty. I am not sure what the right fix would be in this case.

Easy to reproduce by just commenting 'if (content == null)' check.

Edit: davmail logs correctly the title of the event, and from what I understand it is read from the body.

infpmandin avatar Apr 25 '25 12:04 infpmandin