api.content.create lacks schema validation
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 101
- Forks
- 62
- Avg merge
- 15h 15m
- Merged PRs (30d)
- 1
Description
As seen in https://community.plone.org/t/creating-custom-dexterity-objects-from-plone-api/7318/ we can currently set an invalid value/type for fields.
In this case the user is setting a str instead of a RichTextValue, which leads to tracebacks like
AttributeError: 'str' object has no attribute 'output_relative_to'
- Expression: "python:context.text.output_relative_to(view.context)"
- Filename: ... egg/plone/app/contenttypes/browser/templates/document.pt
- Location: (line 15: col 29)
- Source: ... ucture python:context.text.output_relative_to(view.context)"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Is this something we need to handle here, or is this something DX should do?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the api.content.create entry point and review the linked community discussion about invalid field values. Reproduce the case where a string is supplied instead of a RichTextValue, then determine whether validation belongs in this API or in Dexterity. Done means invalid values are handled with a clear validation error rather than a later template traceback.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 32/100