From 3e336237ab030331c137f1533b26df826d9ae8b2 Mon Sep 17 00:00:00 2001 From: Andrey Zhavoronkov Date: Mon, 30 Nov 2020 14:30:18 +0300 Subject: [PATCH 1/3] fixed getTaskPreview exception handling, slightly improved the backend exception handling --- cvat-ui/src/actions/tasks-actions.ts | 2 +- cvat/apps/engine/views.py | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/cvat-ui/src/actions/tasks-actions.ts b/cvat-ui/src/actions/tasks-actions.ts index bf1ba2e42562..349cd880f034 100644 --- a/cvat-ui/src/actions/tasks-actions.ts +++ b/cvat-ui/src/actions/tasks-actions.ts @@ -93,7 +93,7 @@ export function getTasksAsync(query: TasksQuery): ThunkAction, {}, } const array = Array.from(result); - const promises = array.map((task): string => (task as any).frames.preview().catch('')); + const promises = array.map((task): string => (task as any).frames.preview().catch(() => '')); dispatch(getInferenceStatusAsync()); diff --git a/cvat/apps/engine/views.py b/cvat/apps/engine/views.py index e8b14daf01eb..aec2f88afaf5 100644 --- a/cvat/apps/engine/views.py +++ b/cvat/apps/engine/views.py @@ -25,7 +25,7 @@ from drf_yasg.utils import swagger_auto_schema from rest_framework import mixins, serializers, status, viewsets from rest_framework.decorators import action -from rest_framework.exceptions import APIException +from rest_framework.exceptions import APIException, NotFound, ValidationError from rest_framework.permissions import SAFE_METHODS, IsAuthenticated from rest_framework.renderers import JSONRenderer from rest_framework.response import Response @@ -427,16 +427,19 @@ def data(self, request, pk): possible_quality_values = ('compressed', 'original') if not data_type or data_type not in possible_data_type_values: - return Response(data='data type not specified or has wrong value', status=status.HTTP_400_BAD_REQUEST) + raise ValidationError(detail='Data type not specified or has wrong value') elif data_type == 'chunk' or data_type == 'frame': if not data_id: - return Response(data='number not specified', status=status.HTTP_400_BAD_REQUEST) + raise ValidationError(detail='Number not specified') elif data_quality not in possible_quality_values: - return Response(data='wrong quality value', status=status.HTTP_400_BAD_REQUEST) + raise ValidationError(detail='Wrong quality value') try: db_task = self.get_object() db_data = db_task.data + if not db_data: + raise NotFound(detail='Cannot find requested data for the task') + frame_provider = FrameProvider(db_task.data) if data_type == 'chunk': @@ -468,7 +471,7 @@ def data(self, request, pk): else: return Response(data='unknown data type {}.'.format(data_type), status=status.HTTP_400_BAD_REQUEST) except APIException as e: - return Response(data=e.default_detail, status=e.status_code) + return Response(data=e.get_full_details(), status=e.status_code) except Exception as e: msg = 'cannot get requested data type: {}, number: {}, quality: {}'.format(data_type, data_id, data_quality) slogger.task[pk].error(msg, exc_info=True) From b40da653b38b58c2f8640ce75b1ddb6d0e03e97c Mon Sep 17 00:00:00 2001 From: Andrey Zhavoronkov Date: Mon, 30 Nov 2020 14:38:46 +0300 Subject: [PATCH 2/3] npm version++ --- cvat-ui/package-lock.json | 2 +- cvat-ui/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cvat-ui/package-lock.json b/cvat-ui/package-lock.json index 5063901fadf7..9fd70cc326dd 100644 --- a/cvat-ui/package-lock.json +++ b/cvat-ui/package-lock.json @@ -1,6 +1,6 @@ { "name": "cvat-ui", - "version": "1.10.8", + "version": "1.10.9", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/cvat-ui/package.json b/cvat-ui/package.json index 135d15f0cc46..e555f248461d 100644 --- a/cvat-ui/package.json +++ b/cvat-ui/package.json @@ -1,6 +1,6 @@ { "name": "cvat-ui", - "version": "1.10.8", + "version": "1.10.9", "description": "CVAT single-page application", "main": "src/index.tsx", "scripts": { From b40863f1a30a754f10531ecd119ab2795998cb45 Mon Sep 17 00:00:00 2001 From: Andrey Zhavoronkov Date: Mon, 30 Nov 2020 14:40:34 +0300 Subject: [PATCH 3/3] updated changelog --- CHANGELOG.md | 1 + cvat/apps/engine/views.py | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 987b5f11c3ba..82897f74b013 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Reset zoom option doesn't work in tag annotation mode () - Canvas is busy error () - Projects view layout fix () +- Fixed the tasks view (infinite loading) when it is impossible to get a preview of the task () ### Security diff --git a/cvat/apps/engine/views.py b/cvat/apps/engine/views.py index aec2f88afaf5..e6d1745efe7a 100644 --- a/cvat/apps/engine/views.py +++ b/cvat/apps/engine/views.py @@ -426,15 +426,15 @@ def data(self, request, pk): possible_data_type_values = ('chunk', 'frame', 'preview') possible_quality_values = ('compressed', 'original') - if not data_type or data_type not in possible_data_type_values: - raise ValidationError(detail='Data type not specified or has wrong value') - elif data_type == 'chunk' or data_type == 'frame': - if not data_id: - raise ValidationError(detail='Number not specified') - elif data_quality not in possible_quality_values: - raise ValidationError(detail='Wrong quality value') - try: + if not data_type or data_type not in possible_data_type_values: + raise ValidationError(detail='Data type not specified or has wrong value') + elif data_type == 'chunk' or data_type == 'frame': + if not data_id: + raise ValidationError(detail='Number is not specified') + elif data_quality not in possible_quality_values: + raise ValidationError(detail='Wrong quality value') + db_task = self.get_object() db_data = db_task.data if not db_data: