mguessan / davmail

DavMail POP/IMAP/SMTP/Caldav/Carddav/LDAP Exchange and Office 365 Gateway - Synced with main subversion repository at
http://davmail.sourceforge.net
GNU General Public License v2.0
580 stars 86 forks source link

davmail + mbsync: 3 BAD unable to handle request: ErrorUnsupportedPropertyDefinition Unsupported sorting definition. #162

Open mrcjkb opened 3 years ago

mrcjkb commented 3 years ago

Hi. I am using mbsync and davmail 5.5.0 to sync to a Kerio Exchange e-mail account. When starting a sync, I encounter the following stack trace:

davmail.exchange.ews.EWSException: ErrorUnsupportedPropertyDefinition Unsupported sorting definition.
 request: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"><soap:Header><t:RequestServerVersion Version="Exchange2010_SP1"/></soap:Header><soap:Body><m:FindItem Traversal="Shallow"><m:ItemShape><t:BaseShape>IdOnly</t:BaseShape><t:AdditionalProperties><t:FieldURI FieldURI="message:IsRead"/><t:ExtendedFieldURI PropertyTag="0x3008" PropertyType="SystemTime"/><t:ExtendedFieldURI DistinguishedPropertySetId="Common" PropertyId="34160" PropertyType="Integer"/><t:ExtendedFieldURI PropertyTag="0x670e" PropertyType="String"/><t:ExtendedFieldURI PropertyTag="0xe07" PropertyType="Integer"/><t:ExtendedFieldURI PropertyTag="0xe08" PropertyType="Integer"/><t:ExtendedFieldURI PropertyTag="0x1083" PropertyType="Integer"/><t:ExtendedFieldURI PropertyTag="0xe06" PropertyType="SystemTime"/><t:ExtendedFieldURI PropertyTag="0x1081" PropertyType="Integer"/><t:ExtendedFieldURI PropertyTag="0x10f3" PropertyType="String"/><t:ExtendedFieldURI PropertyTag="0xff9" PropertyType="Binary"/><t:ExtendedFieldURI DistinguishedPropertySetId="InternetHeaders" PropertyName="content-class" PropertyType="String"/><t:ExtendedFieldURI DistinguishedPropertySetId="PublicStrings" PropertyName="Keywords" PropertyType="StringArray"/><t:ExtendedFieldURI PropertyTag="0xe23" PropertyType="Integer"/><t:ExtendedFieldURI PropertyTag="0x1090" PropertyType="Integer"/></t:AdditionalProperties></m:ItemShape><m:IndexedPageItemView MaxEntriesReturned="500" Offset="0" BasePoint="Beginning"/><m:SortOrder><t:FieldOrder Order="Ascending"><t:ExtendedFieldURI PropertyTag="0xe23" PropertyType="Integer"/></t:FieldOrder></m:SortOrder><m:ParentFolderIds><t:DistinguishedFolderId Id="inbox"/></m:ParentFolderIds></m:FindItem></soap:Body></soap:Envelope>
    at davmail.exchange.ews.EWSMethod.checkSuccess(EWSMethod.java:778)
    at davmail.exchange.ews.EwsExchangeSession.internalExecuteMethod(EwsExchangeSession.java:2997)
    at davmail.exchange.ews.EwsExchangeSession.executeMethod(EwsExchangeSession.java:2960)
    at davmail.exchange.ews.EwsExchangeSession.searchItems(EwsExchangeSession.java:747)
    at davmail.exchange.ews.EwsExchangeSession.searchItems(EwsExchangeSession.java:680)
    at davmail.exchange.ews.EwsExchangeSession.searchMessages(EwsExchangeSession.java:664)
    at davmail.exchange.ExchangeSession.searchMessages(ExchangeSession.java:314)
    at davmail.exchange.ExchangeSession$Folder.loadMessages(ExchangeSession.java:1184)
    at davmail.imap.ImapConnection.run(ImapConnection.java:229)
mrcjkb commented 3 years ago

I have tracked down the issue to the following line in EwsExchangeSession:

findItemMethod.setFieldOrder(new FieldOrder(Field.get("imapUid"), FieldOrder.Order.Ascending));

Commenting out that line causes the request to be successful (with a HttpStatus.SC_OK status code).

But now the line

long imapUid = Long.parseLong(item.get(Field.get("imapUid").getResponseName()));

fails, because item.get(Field.get("imapUid").getResponseName()) returns null.

mrcjkb commented 3 years ago

The null pointer issue has already been fixed on master. But authentication does not seem to be working on master Adding a null check and commenting out the setFieldOrder call seems to resolve the issue for me.

Is it feasible to add an option to disable or configure the FieldOrder sorting configuration?