-
-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Returns an error message when an Invalid occurs when validating a controlpanel field #1771
Conversation
@wesleybl thanks for creating this Pull Request and helping to improve Plone! TL;DR: Finish pushing changes, pass all other checks, then paste a comment:
To ensure that these changes do not break other parts of Plone, the Plone test suite matrix needs to pass, but it takes 30-60 min. Other CI checks are usually much faster and the Plone Jenkins resources are limited, so when done pushing changes and all other checks pass either start all Jenkins PR jobs yourself, or simply add the comment above in this PR to start all the jobs automatically. Happy hacking! |
✅ Deploy Preview for plone-restapi canceled.
|
@jenkins-plone-org please run jobs |
When deserializing the controlpanel, do not return the "error" key as an object, but rather as a string "ValidationError". On the front end, we are unable to convert an object to json. So we need to return a string. This is the same way content deserialization does.
@jenkins-plone-org please run jobs |
@wesleybl Could you add a screenshot of how the error looks now, or give me steps to reproduce it? I can probably figure it out but I'm skimming through a bunch of issues this evening, and it's easier to click "accept" quickly if I can clearly see what the result of the change is. |
@davisagli the steps to reproduce this on the Volto are described in: plone/volto#5274 But this PR here does not make validation errors appear in Volto. It only leaves the compatible restapi response to be displayed in Volto. I'm preparing a PR on Volto to display the errors. But this PR here doesn't "break the screen" if my Volto PR isn't ready. So it's safe to merge first. With this PR the response with validation error looks like this: {
"message": "[{'message': 'Twitter username should not include the \"@\" prefix character.', 'field': 'twitter_username', 'error': 'ValidationError'}]",
"traceback": [
"File \"/home/user/.buildout/eggs/cp311/Zope-5.8.5-py3.11.egg/ZPublisher/WSGIPublisher.py\", line 181, in transaction_pubevents",
" yield",
"",
" File \"/home/user/.buildout/eggs/cp311/Zope-5.8.5-py3.11.egg/ZPublisher/WSGIPublisher.py\", line 391, in publish_module",
" response = _publish(request, new_mod_info)",
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^",
"",
" File \"/home/user/.buildout/eggs/cp311/Zope-5.8.5-py3.11.egg/ZPublisher/WSGIPublisher.py\", line 285, in publish",
" result = mapply(obj,",
" ^^^^^^^^^^^",
"",
" File \"/home/user/.buildout/eggs/cp311/Zope-5.8.5-py3.11.egg/ZPublisher/mapply.py\", line 98, in mapply",
" return debug(object, args, context)",
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^",
"",
" File \"/home/user/.buildout/eggs/cp311/Zope-5.8.5-py3.11.egg/ZPublisher/WSGIPublisher.py\", line 68, in call_object",
" return obj(*args)",
" ^^^^^^^^^^",
"",
" File \"/home/user/.buildout/eggs/cp311/plone.rest-3.0.1-py3.11.egg/plone/rest/service.py\", line 22, in __call__",
" return self.render()",
" ^^^^^^^^^^^^^",
"",
" File \"/home/user/git/plone.restapi/src/plone/restapi/services/__init__.py\", line 19, in render",
" content = self.reply()",
" ^^^^^^^^^^^^",
"",
" File \"/home/user/git/plone.restapi/src/plone/restapi/services/controlpanels/update.py\", line 41, in reply",
" deserializer() # The deserializer knows where to put it.",
" ^^^^^^^^^^^^^^",
"",
" File \"/home/user/git/plone.restapi/src/plone/restapi/deserializer/controlpanels/__init__.py\", line 89, in __call__",
" raise BadRequest(errors)"
],
"type": "BadRequest"
} |
@davisagli I make the Volto PR: plone/volto#5950 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and works fine with plone/volto#5950
@jenkins-plone-org please run jobs |
@tisto @davisagli @sneridagh can you take a look here please? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested in combination with plone/volto#5950, looks good. thanks @wesleybl!
@jenkins-plone-org please run jobs |
@jenkins-plone-org please run jobs |
Also translates the message.
Ref: plone/volto#5274