plone.restapi
plone.restapi copied to clipboard
Error in creation of item
I'm not sure why I got this error, I didn't look at the request, but it seems there should be an extra check for the None
return type from portal_types.getTypeInfo(type_)
^[2021-07-30 10:12:59,567 ERROR [Zope.SiteErrorLog:252][waitress-1] 1627639979.5669810.8745619770145149 http://localhost:3000/search/POST_application_json_
Traceback (innermost last):
Module ZPublisher.WSGIPublisher, line 162, in transaction_pubevents
Module ZPublisher.WSGIPublisher, line 371, in publish_module
Module ZPublisher.WSGIPublisher, line 274, in publish
Module ZPublisher.mapply, line 85, in mapply
Module ZPublisher.WSGIPublisher, line 63, in call_object
Module plone.rest.service, line 22, in __call__
Module plone.restapi.services, line 19, in render
Module plone.restapi.services.content.add, line 55, in reply
Module plone.restapi.services.content.utils, line 37, in create
AttributeError: 'NoneType' object has no attribute 'isConstructionAllowed'
https://github.com/plone/plone.restapi/blob/02421afe76b53414ee569bb42077248b45d6e8e8/src/plone/restapi/services/content/utils.py#L37
@tiberiuichim maybe a proper error message when the type info of a content object can not be looked up properly. A sample request would help a lot to figure out why things went wrong.
curl 'http://localhost:55001/plone/' \
-H 'Proxy-Connection: keep-alive' \
-H 'sec-ch-ua: "Chromium";v="91", " Not;A Brand";v="99"' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZG1pbiIsImV4cCI6MTYyNzk0NTkxNiwiZnVsbG5hbWUiOm51bGx9.8MQGXL9fHASLGbFBaHYkHji6pFiQZcMLo5Ro5wdB6Hs' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36' \
-H 'Content-Type: application/json' \
-H 'Sec-Fetch-Site: same-site' \
-H 'Sec-Fetch-Mode: cors' \
-H 'Sec-Fetch-Dest: empty' \
-H 'Referer: http://localhost:3000/' \
-H 'Accept-Language: en-US,en;q=0.9' \
-H 'Cookie: auth_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZG1pbiIsImV4cCI6MTYyNzk0NTkxNiwiZnVsbG5hbWUiOm51bGx9.8MQGXL9fHASLGbFBaHYkHji6pFiQZcMLo5Ro5wdB6Hs; lang=en; I18N_LANGUAGE=en' \
--data-raw '{"blocks":{"9f2bc9bc-6efb-49a1-b10d-f57502f28372":{"@type":"title"},"66b86835-8be1-4783-9cdd-779806bdf86f":{"@type":"text"},"e68f2315-c380-4dfa-bd7e-94e51d230c70":{"@type":"searchBlock","showSearchInput":true,"searchInputPrompt":"Type search term:","query":{"query":[{"i":"portal_type","o":"plone.app.querystring.operation.selection.any","v":["Document"]}],"sort_order":"ascending"},"facets":[{"@id":"fbe25d3b-83a4-4e20-99ae-0b1436cdbdd4","field":{"label":"Review state","value":"review_state"},"type":"checkboxFacet"}]}},"blocks_layout":{"items":["9f2bc9bc-6efb-49a1-b10d-f57502f28372","e68f2315-c380-4dfa-bd7e-94e51d230c70","66b86835-8be1-4783-9cdd-779806bdf86f"]},"exclude_from_nav":false,"language":"en","relatedItems":[],"title":"Test search page","@static_behaviors":null,"@type":"Default"}' \
--compressed
I figured it out... my custom block was rewriting the URL location and erasing the ?type=Document
from the query.
@tiberiuichim what about improving the error response of plone.restapi here? :)
If experienced Plone devs have a hard time figuring out what happened here, newbies will be totally lost...