From 830dc58c7876db6e24c9bb96119f997ce2c162ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Szulc?= Date: Fri, 8 Nov 2024 11:09:50 +0100 Subject: [PATCH] Add 404 if no serializer found for dc-hosts endpoint --- src/ralph/assets/api/views.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ralph/assets/api/views.py b/src/ralph/assets/api/views.py index 4aa0ac92d4..b0c25e25a2 100644 --- a/src/ralph/assets/api/views.py +++ b/src/ralph/assets/api/views.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- import django_filters from django.db.models import Prefetch -from rest_framework.exceptions import ValidationError +from rest_framework.exceptions import NotFound, ValidationError from rest_framework.permissions import SAFE_METHODS from ralph.api import RalphAPIViewSet @@ -317,6 +317,8 @@ def get_serializer_class(self, *args, **kwargs): elif isinstance(obj_, Cluster): from ralph.data_center.api.serializers import ClusterSerializer return ClusterSerializer + else: + raise NotFound() except AssertionError: # for some reason when opening browsable api this raises pass return serializers.DCHostSerializer