handle service error
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 12s

This commit is contained in:
2026-08-02 19:58:00 +05:00
parent 3397f212b5
commit 192f987125
2 changed files with 42 additions and 0 deletions
+40
View File
@@ -615,3 +615,43 @@ class RetrieveUpdateDestroyIslandView(
if name and Island.objects.filter(name=name).exclude(pk=instance.pk).exists():
return Response({"message": "Island name already exists."}, status=400)
return super().update(request, *args, **kwargs)
class PersonVerifyAPIView(StaffEditorPermissionMixin, generics.GenericAPIView):
"""
Admin-gated proxy to the external Person verification API.
The SPA frontend can no longer call the external person-verify service
directly (it would leak an internal infra host to the browser), so the
backend owns the integration. Returns the upstream JSON as-is.
GET /api/auth/person/<id_card>/
"""
def get(self, request, id_card: str, *args, **kwargs):
import requests
from decouple import config
PERSON_VERIFY_BASE_URL = config("PERSON_VERIFY_BASE_URL", default="") # type: ignore
if not PERSON_VERIFY_BASE_URL:
return Response(
{"detail": "PERSON_VERIFY_BASE_URL is not set."},
status=status.HTTP_500_INTERNAL_SERVER_ERROR,
)
try:
upstream = requests.get(
f"{PERSON_VERIFY_BASE_URL}/api/person/{id_card}", timeout=10
)
except requests.RequestException as exc:
return Response(
{"detail": f"Failed to reach person verification service: {exc}"},
status=status.HTTP_502_BAD_GATEWAY,
)
try:
data = upstream.json()
except ValueError:
return Response(
{"detail": "Invalid response from person verification service."},
status=status.HTTP_502_BAD_GATEWAY,
)
return Response(data, status=upstream.status_code)