mirror of
https://github.com/suitenumerique/docs
synced 2026-04-21 13:37:20 +00:00
🐛(backend) Fix unreachable exception handler for URLValidator
The exception block was never being executed because URLValidator raises django.core.exceptions.ValidationError, not drf.exceptions.ValidationError, so the except block was dead code. Signed-off-by: Mohamed El Amine BOUKERFA <boukerfa.ma@gmail.com>
This commit is contained in:
parent
d0bf24f368
commit
1ebdda8c9e
2 changed files with 2 additions and 2 deletions
|
|
@ -2135,7 +2135,7 @@ class DocumentViewSet(
|
|||
url_validator = URLValidator(schemes=["http", "https"])
|
||||
try:
|
||||
url_validator(url)
|
||||
except drf.exceptions.ValidationError as e:
|
||||
except ValidationError as e:
|
||||
return drf.response.Response(
|
||||
{"detail": str(e)},
|
||||
status=drf.status.HTTP_400_BAD_REQUEST,
|
||||
|
|
|
|||
|
|
@ -255,7 +255,7 @@ def test_api_docs_cors_proxy_invalid_url(url_to_fetch):
|
|||
f"/api/v1.0/documents/{document.id!s}/cors-proxy/?url={url_to_fetch}"
|
||||
)
|
||||
assert response.status_code == 400
|
||||
assert response.json() == ["Enter a valid URL."]
|
||||
assert response.json() == {"detail": "['Enter a valid URL.']"}
|
||||
|
||||
|
||||
@unittest.mock.patch("core.api.viewsets.socket.getaddrinfo")
|
||||
|
|
|
|||
Loading…
Reference in a new issue