pitchmuc / aepp

Adobe Experience Platform API for humans

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Creating a descriptor is not working due to missing xdm:property

cmenguy opened this issue · comments

Currently if I try to create a descriptor with createDescriptor in schema.py it is failing because of the missing xdm:property field. See error below:

Out[262]: {'type': 'http://ns.adobe.com/aep/errors/XDM-4000-400', 'title': 'Validation error', 'status': 400, 'report': {'registryRequestId': 'd754ef24-8a43-4625-9742-3cd86156fce8', 'timestamp': '02-03-2023 08:02:43', 'detailed-message': 'An error occurred validating the schema.', 'sub-errors': [{'path': '$', 'type': 'required', 'arguments': ['xdm:property'], 'message': '$.xdm:property: is missing but it is required'}]}, 'detail': 'An error occurred validating the schema.'}

The only way to get this function working now seems to be by just passing the raw object with descriptorObj but we should modify the function to ensure it works with the parameters.

commented

Hey @cmenguy
You are correct, the problem is that each type of descriptor require different type of property, which makes the checking quite difficulte.
I will probably provide a way to do it programmatically but for your info:
I have recently introduced a new way to manage schema that would be easier for users not that familiar with Schema management via API.

There is a new class called SchemaManager that takes the schema ID or schema definition that allows you to do different tasks directly in the schema.
One of them is createDescriptorOperation and there you could create the object via parameters and then use it in the createDescriptor method.

This is an extra step but the SchemaManager class is doing so much cool stuffs (including the FieldGroupManager operation) that you may want to check it out.
I am building the documentation at the moment as it is quite recent and this is weekend work.

commented

The easiest way for me to support any type of property for descriptor without bloating the code the way the createDescriptorOperation is, is to do the following:
checking if the kwargs added contains the xdm: value so I add it to the data passed.

for key in kwargs:
    if 'xdm:' in key:
        obj[key] = kwargs.get(key)
commented

Release on 0.2.6 (now available on pypi)