Skip to content

Commit

Permalink
refactor: Lint agents-api (CI)
Browse files Browse the repository at this point in the history
  • Loading branch information
creatorrr authored and github-actions[bot] committed Nov 2, 2024
1 parent c86435a commit 7eeeac3
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions agents-api/agents_api/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,13 @@ def make_exception_handler(status_code: int) -> Callable[[Any, Any], Any]:
"""

async def _handler(request: Request, exc: Exception):

location = None
offending_input = None

# Return the deepest matching possibility
if isinstance(exc, (ValidationError, RequestValidationError)):
errors = exc.errors()

# Get the deepest matching errors
max_depth = max(len(error["loc"]) for error in errors)
errors = [error for error in errors if len(error["loc"]) == max_depth]
Expand Down Expand Up @@ -97,7 +96,7 @@ async def _handler(request: Request, exc: Exception):
break

offending_input = offending_input[loc]

# Keep only the message from the error
errors = [error.get("msg", error) for error in errors]

Expand Down

0 comments on commit 7eeeac3

Please sign in to comment.