Skip to content

Commit

Permalink
Fix bug related to error type handling
Browse files Browse the repository at this point in the history
  • Loading branch information
fdalmaup authored and Selutario committed May 23, 2024
1 parent 023f6ce commit 548f612
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions api/api/error_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,9 @@ async def problem_error_handler(request: ConnexionRequest, exc: exceptions.Probl
"""
problem = {
"title": exc.title if exc.title else 'Bad Request',
"detail": exc.detail if isinstance(exc.detail, dict) \
else _cleanup_detail_field(exc.detail)
"detail": exc.detail if isinstance(exc.detail, dict) else _cleanup_detail_field(exc.detail)
}
problem.update({"type": exc.type} if exc.type else {})
problem.update({"type": exc.type} if (exc.type and exc.type != 'about:blank') else {})
problem.update(exc.ext if exc.ext else {})
if isinstance(problem['detail'], dict):
for field in ['status', 'type']:
Expand Down
2 changes: 1 addition & 1 deletion api/api/test/test_error_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ async def test_problem_error_handler(title, detail, ext, error_type, mock_reques
detail = _cleanup_detail_field(detail)
problem = {}
problem.update({'title': title} if title else {'title': 'Bad Request'})
problem.update({'type': error_type} if error_type else {})
problem.update({'type': error_type} if (error_type and error_type != 'about:blank') else {})
problem.update({'detail': detail} if detail else {})
problem.update(ext if ext else {})
problem.update({'error': problem.pop('code')} if 'code' in problem else {})
Expand Down

0 comments on commit 548f612

Please sign in to comment.