PostHog / drf-exceptions-hog

Standardized and easy-to-parse API error responses for Django REST Framework (DRF).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

key error when exception contains __all__ key

abtinmo opened this issue · comments

commented

Hey guys, thank you for your great package.
when using full_clean to validate incoming data, in some cases like unique validation, serializer will return exception with __all__ key.

example of exception:
'__all__': [ErrorDetail(string='User with this Name and Email already exists.', code='unique_together')

exception occurred in this line:
https://github.com/PostHog/drf-exceptions-hog/blob/master/exceptions_hog/handler.py#L130

Hi @abtinmo! Thanks for your feedback on helping us improve this, I do apologize for the delay here, we've been swamped. Will try to get a solution out in the upcoming couple of weeks. Keep you posted here.

commented

Hey @paolodamico, i saw you already created a fix for it.

based on you solution, could we also replace non_field_errors with None?

https://www.django-rest-framework.org/api-guide/settings/#non_field_errors_key

Makes sense @abtinmo, thanks for the suggestion, I've updated the PR.