plone.restapi icon indicating copy to clipboard operation
plone.restapi copied to clipboard

Returns an error message when an Invalid occurs when validating a controlpanel field

Open wesleybl opened this issue 3 months ago • 7 comments

Also translates the message.

Ref: https://github.com/plone/volto/issues/5274

wesleybl avatar Apr 02 '24 18:04 wesleybl

@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:

@jenkins-plone-org please run jobs

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!

mister-roboto avatar Apr 02 '24 18:04 mister-roboto

Deploy Preview for plone-restapi canceled.

Name Link
Latest commit c8adc970ee539fdc401a0ff8ac0270094010dccd
Latest deploy log https://app.netlify.com/sites/plone-restapi/deploys/66310358e831fc0008d11827

netlify[bot] avatar Apr 02 '24 18:04 netlify[bot]

@jenkins-plone-org please run jobs

wesleybl avatar Apr 02 '24 18:04 wesleybl

@jenkins-plone-org please run jobs

wesleybl avatar Apr 03 '24 17:04 wesleybl

@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 avatar Apr 04 '24 03:04 davisagli

@davisagli the steps to reproduce this on the Volto are described in: https://github.com/plone/volto/issues/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"
}

wesleybl avatar Apr 04 '24 15:04 wesleybl

@davisagli I make the Volto PR: https://github.com/plone/volto/pull/5950

wesleybl avatar Apr 05 '24 19:04 wesleybl

@jenkins-plone-org please run jobs

wesleybl avatar Apr 23 '24 21:04 wesleybl

@tisto @davisagli @sneridagh can you take a look here please?

wesleybl avatar Apr 23 '24 21:04 wesleybl

@jenkins-plone-org please run jobs

davisagli avatar Apr 29 '24 21:04 davisagli

@jenkins-plone-org please run jobs

wesleybl avatar Apr 30 '24 14:04 wesleybl