plone / plone/plone.restapi

Deserializer could include the value of a field with validation error within the error message

Open
#1,378 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
109
Forks
107
Avg merge
2d 3h
Merged PRs (30d)
4

Description

collective.exportimport uses this code

deserializer = getMultiAdapter((new, self.request), IDeserializeFromJson)

which sometimes produces a validation error like (from some field value not matching the field constraints)

BadRequest([{'message': 'The specified URI is not valid.', 'field': 'url', 'error': 'ValidationError'}])

I would be often super useful having direct access to the offending value.
Perhaps one could include the string representation together with the BadRequest exception?
Problem might be large data, overlong strings or so.

Thoughts?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the collective.exportimport call to getMultiAdapter((new, self.request), IDeserializeFromJson) and trace how its validation errors become BadRequest responses. Define how the offending field value should be represented and bounded, then verify that validation errors expose it without producing unwieldy messages.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.