Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [UNRELEASED]
### Fixed
- stop ignoring exceptions with detail as an empty string when returning api errors.

## [0.14.0] - 2024-06-19
### Added
Expand Down
2 changes: 1 addition & 1 deletion drf_standardized_errors/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def flatten_errors(
errors = []
while fifo:
detail, attr, index = fifo.pop(0)
if not detail:
if not detail and detail != "":
continue
elif isinstance(detail, list):
for item in detail:
Expand Down
8 changes: 8 additions & 0 deletions tests/test_flatten_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,11 @@ def test_does_not_raise_recursion_error():
"Failed due to a recursion error. Use an iterative approach rather than "
"a recursive one to avoid reaching the maximum recursion depth in python."
)


def test_exception_with_detail_empty():
detail = {"some_field": [ErrorDetail("", code="invalid")]}
errors = flatten_errors(detail)
assert len(errors) == 1
assert errors[0].attr == "some_field"
assert errors[0].detail == ""