[plone.restapi] 'Schema not provided' errors

As part of a migration, I see this error for the field inrete:

  File "/home/ajung/src/unibo/magazine-plone6/eggs/plone.restapi-8.43.3-py3.11.egg/plone/restapi/deserializer/dxcontent.py", line 60, in __call__
    raise BadRequest(errors)
zExceptions.BadRequest: [{'message': 'Schema not provided', 'field': 'inrete', 'error': 'ValidationError'}

with input data like

    "inrete": [
        {
             
            "link": "http://www.ifla.org/en/events/moving-in-moving-up-and-moving-on-strategies-for-regenerating-the-library-and-information-pro", 
            "title": "La pagina web dell'evento"
        }
    ], 

The inrete field comes from a behavior defined as

class IInRete(Interface):

    title = schema.TextLine(
        title=_(u"Titolo"),
        description=_(u"Titolo del contenuto in rete"),
        required=True,
    )

    link = schema.URI(
        title=_(u"Url"),
        description=_(u"Inserisci un indirizzo web"),
        required=True,
        default="http://",
    )

class IInReteBehavior(model.Schema):

    inrete = schema.List(
        title=_(u"In Rete"),
        required=False,
        value_type=schema.Object(
            title=_(u"In rete"),
            schema=IInRete,
        ),
    

I am not getting the point of this Schema not provided error.
I am using latest Plone 6.0.7.
Any idea?

In the json, there's a list of dictionary but there's no information about the content type in the dictionary. Is this ok?

I see you clearly define a schema IInRete and pass it to the schema.Object constructor via:

schema=IInRete,

Might it be that IInRete should inherit from model.Schema as well instead of Interface?

...makes no difference

I have not seen supplementary type information other than @type in exports.

I'd drop a breakpoint() somewhere in https://github.com/plone/plone.restapi/blob/3927a8978b7242189c74d15668dd809674a2c5ea/src/plone/restapi/deserializer/dxcontent.py#L54C12-L60 to see what the actual error is.

Feels like it would be zope.schema._bootstrapinterfaces — zope.schema 4.9.3 documentation and the validator.validate call at https://github.com/plone/plone.restapi/blob/3927a8978b7242189c74d15668dd809674a2c5ea/src/plone/restapi/deserializer/dxcontent.py#L51 needs some tinkering.

was this field seralized with plone.restapi?

I doubt that there's an implementation of value_type=schema.Object in plone.restapi ... at least I didn't find anything here https://github.com/plone/plone.restapi/blob/main/src/plone/restapi/deserializer/configure.zcml ...

As an alternative you could use collective.z3cform.datagridfield which has a deserizalizer for:

from collective.z3cform.datagridfield.row import DictRow

... 

class IInReteBehavior(model.Schema):

    inrete = schema.List(
        title=_(u"In Rete"),
        required=False,
        value_type=DictRow(
            title=_(u"In rete"),
            schema=IInRete,
        ),
    )
1 Like

The input data comes from an export with collective.exportimport==1.9.

The final solution/workaround for our usecase (with a known list of fields):

  • renamed the inrete to _inrete in order to avoid the deserializer issue
  • look over the migration data in a dedicated step, checking for _inrete fields
    and assigning the data directly to the affected objects

Not perfect but straight forward...