Skip to content

Handle create-user 500 responses where body contains 'message' instead of 'error'#7946

Merged
sneridagh merged 3 commits intomainfrom
users-create-error-message
Mar 2, 2026
Merged

Handle create-user 500 responses where body contains 'message' instead of 'error'#7946
sneridagh merged 3 commits intomainfrom
users-create-error-message

Conversation

@wesleybl
Copy link
Copy Markdown
Member

When the server returns HTTP 500 during user creation (for example due to an SMTP MailHost error), the response body may not include an 'error' key and instead contains a top-level 'message'. This caused a runtime TypeError when trying to read 'response.body.error.message'.

This change makes the client tolerant of that shape by extracting 'response.body.message' when 'response.body.error' is absent, falling back to other error fields. It prevents reading properties of undefined and ensures a readable error string is shown to the user.

…d of 'error'

When the server returns HTTP 500 during user creation (for example due to an SMTP MailHost error), the response body may not include an 'error' key and instead contains a top-level 'message'. This caused a runtime TypeError when trying to read 'response.body.error.message'.

This change makes the client tolerant of that shape by extracting 'response.body.message' when 'response.body.error' is absent, falling back to other error fields. It prevents reading properties of undefined and ensures a readable error string is shown to the user.
Copy link
Copy Markdown
Member

@davisagli davisagli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

I think the root of the problem here is that the @users endpoint was using a non-standard way of serializing errors (https://github.com/plone/plone.restapi/blob/main/src/plone/restapi/services/users/add.py#L291) -- which uses "error" -- instead of raising an exception and letting it get serialized by the exception view in plone.rest (https://github.com/plone/plone.rest/blob/main/src/plone/rest/errors.py) -- which uses "message"

We should update the users service to raise exceptions the standard way. But in order to do that smoothly we have to accept both ways here, so this is good.

I'm making a suggestion to move this into helpers so we can use it from other places in Volto too. I'll let you decide whether to do that or merge it as is.

Comment thread packages/volto/src/components/manage/Controlpanels/Users/UsersControlpanel.jsx Outdated
@sneridagh sneridagh merged commit 71f042f into main Mar 2, 2026
77 checks passed
@sneridagh sneridagh deleted the users-create-error-message branch March 2, 2026 11:00
wesleybl added a commit that referenced this pull request Mar 7, 2026
sneridagh added a commit that referenced this pull request Mar 19, 2026
* main: (122 commits)
  Release 19.0.0-alpha.27
  Release @plone/slate 19.0.0-alpha.12
  Release @plone/razzle 1.0.0-alpha.1
  We do not release @plone/client from here
  Handle create-user 500 responses where body contains 'message' instead of 'error' (#7946)
  Dropzone filewidget a11y (#7956)
  Update css-minimizer-webpack-plugin to v7 and keep razzleOptions.enableSourceMaps control (#7934)
  Refactor Password Reset: Convert Class-Based Component to Functional Component (#7697)
  fix: Fixed searchable types in Object Browser Widget, adding also sel… (#7942)
  Fix in-page drag-and-drop for the Listing block in Volto 18 and 19 (#7907)
  Improved docs of Plone REST API JavaScript Client (#5576)
  Fix Moderate Comments control panel visibility based on Discussion Support addon installation (#7878)
  fix: Add authorization error handling to control panels (#7807)
  Fix subordering order tab (#7937) (#7939)
  Fix converting value to html in HtmlSlateWidget (#7938)
  razzle.config.js: Fix defaultPlugins missing name property to enable addon SCSS plugin replacement (#7908)
  Update users controlpanel to work with new response format (#7895)
  Avoid storing blocksClipboard in localstorage until it has a value (#7925)
  Remove link to Jobfamilie MEDICE: site is no longer a Volto site (redirects to non-Volto destination) (#7929)
  Exclude `.storybook` from ESLint's default hidden directory ignore list via `.eslintignore` to allow linting of Storybook configuration files (#7898)
  ...
davisagli pushed a commit to Manik-Khajuria-5/volto that referenced this pull request May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants