Skip to content

Commit 67c607a

Browse files
Potential fix for code scanning alert no. 10: Information exposure through an exception
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 38e039a commit 67c607a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

api/views/aimodel_detail.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from typing import Any, Dict, List, Optional
44

5+
import logging
56
from rest_framework import serializers, status
67
from rest_framework.permissions import AllowAny
78
from rest_framework.request import Request
@@ -11,6 +12,8 @@
1112
from api.models.AIModel import AIModel, ModelEndpoint
1213

1314

15+
logger = logging.getLogger(__name__)
16+
1417
class ModelEndpointSerializer(serializers.ModelSerializer):
1518
"""Serializer for Model Endpoint."""
1619

@@ -125,4 +128,5 @@ def get(self, request: Request, model_id: str) -> Response:
125128
except AIModel.DoesNotExist:
126129
return Response({"error": "AI Model not found"}, status=404)
127130
except Exception as e:
128-
return Response({"error": str(e)}, status=500)
131+
logger.exception("Unexpected exception in AIModelDetailView.get")
132+
return Response({"error": "An internal error has occurred."}, status=500)

0 commit comments

Comments
 (0)