-
Notifications
You must be signed in to change notification settings - Fork 8
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
drf-problems fields overwrite Validation field info #5
Comments
It should be noted that I have no control over these fields - they are in a third-party Django app, and that app is critical, and my project is in production, so hacking about in critical third-party apps renaming their fields is not happening. I can change the front-end to suit drf-problems - but drf-problems needs to not conflict with other Django apps. One approach used by other drf exception handlers is to move field validation errors down to a new subkey under the root. I really appreciate that this app keeps the validation errors unmodified at the top node - that is great for compatibility, and easy adoption. But IMO copying the field validation errors to a subkey will allow clients to fix their code to use the subkey only in the areas where it is necessary because drf-problems is overwriting I think there should be a config setting like Then existing sites with clients already expecting field validation errors in the root can disable Adding a new subkey introduces another key which could conflict with the original response, so it is worth thinking about it carefully, and possibly also worth adding a setting so sites can change it if it is causing them problems.
IMO, So, IMO, an improbable default key like |
Hmm, I see that else:
data = dict(errors=response.data, title=problem_title,
status=problem_status, type=problem_type) |
That sounds like a good idea. Since this library ensures view responses are valid RFC 7807 response,
I think asking user for the key in config setting would suffice. Something like |
If there is a serializer data validation error on a field
title
,status
ortype
, the validation message will be overwritten by drf-problems which forces exception meta info into those fields.The text was updated successfully, but these errors were encountered: