ecederstrand/exchangelib

Incorrect "field_uri" in BaseFolder._distinguished_id

FirePanda169 opened this issue · 1 comments

Describe the bug
_distinguished_id = IdElementField(field_uri="folder:FolderId", value_cls=DistinguishedFolderId)

class BaseFolder(RegisterMixIn, SearchableMixIn, SupportedVersionClassMixIn, metaclass=EWSMeta):
... 
    _distinguished_id = IdElementField(field_uri="folder:FolderId", value_cls=DistinguishedFolderId)
...

field_uri is incorrect.

How fix
I don’t understand why I get this answer. For now I will use this solution

class BaseFolder(RegisterMixIn, SearchableMixIn, SupportedVersionClassMixIn, metaclass=EWSMeta):
... 
    _distinguished_id = CharField(field_uri="folder:DistinguishedFolderId")
...

To Reproduce
This is how the request is built and the answer comes to it.

GetFolder(account=self.account).call(
    folders = [FolderId(id=folder_oid)],
    additional_fields = {
        FieldPath(field=f)
        for f in (Folder._distinguished_id, Folder.folder_class, Folder.name)
    },
    shape = "IdOnly"
)

Request:

...
<t:AdditionalProperties>
    <t:FieldURI FieldURI="folder:DisplayName" />
    <t:FieldURI FieldURI="folder:FolderClass" />
    <t:FieldURI FieldURI="folder:FolderId" />
</t:AdditionalProperties>
...

Response

...
<t:FolderId Id="..." ChangeKey="..."/>
<t:FolderClass>IPF.Note</t:FolderClass>
<t:DisplayName>Sync Issues</t:DisplayName>
...

Expected behavior
docs: https://learn.microsoft.com/en-us/exchange/client-developer/web-service-reference/distinguishedfolderid
I expect that he will make a request and a response will come to him
Request:

...
<t:AdditionalProperties>
    <t:FieldURI FieldURI="folder:DisplayName" />
    <t:FieldURI FieldURI="folder:FolderClass" />
    <t:FieldURI FieldURI="folder:DistinguishedFolderId" />
</t:AdditionalProperties>
...

Response

...
<t:FolderId Id="..." ChangeKey="..."/>
<t:FolderClass>IPF.Note</t:FolderClass>
<t:DisplayName>Sync Issues</t:DisplayName>
<t:DistinguishedFolderId>syncissues</t:DistinguishedFolderId>
...

Log output

Additional context
Python 3.11.8
exchangelib 5.2.0

Thanks for the report!

I vaguely remember certain versions of Exchange not returning anything in DistinguishedFolderId even for distinguished folders, but I cannot reproduce that now.