dandi / dandi/dandi-schema

Use full information from `ValidationError` to form error messages

Open
#246 1 comment 0 reactions 1 assignee Claimed by @waxlamp View on GitHub
Dominant language
Python
Stars
7
Forks
15
PR merge metrics
No merged PRs in 30d

Description

[This gist](https://gist.github.com/waxlamp/5966f1d2290c218f5fc51354b01069ca) demonstrates how Pydantic validation errors can indicate the exact value within the "tree" of values caused a failure, its location, and a machine-readable error type. This information could be used to immediately improve validation error messages (by just including the value and location).

A longer-term improvement would be to use the machine-readable tag plus the field name to "translate" "nerd" messages ("This string failed to match this regex") into "end user" messages ("The `name` field of a `Person` contributor should be in the form of `, ` (some examples: `Doe, Jane`; `Picard, Jean-Luc`; `Hornblower, Horatio`").

I plan to send a proof-of-concept PR demonstrating one way `dandischema` could accomplish this.

This issue originated from https://github.com/dandi/dandi-archive/issues/713 and then more recently from https://github.com/dandi/dandi-archive/issues/1958. @mvandenburgh has filed #245 (and #244) to deal with Pydantic's [default algorithm for validating `Union`s](https://docs.pydantic.dev/latest/concepts/unions/#smart-mode); this issue has more to do with improving error messages across the board.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.