diff --git a/docs/CHANGELOG.rst b/docs/CHANGELOG.rst index 124f0c663..8fd542ce2 100644 --- a/docs/CHANGELOG.rst +++ b/docs/CHANGELOG.rst @@ -6,6 +6,15 @@ All notable changes to this project are documented in this file. This project adheres to `Semantic Versioning `_. +=================== +42.0.2 - 2024-12-02 +=================== + +Fixed +----- +- Fix ``AnnotationValueViewSet`` crash when removing the delete markers + + =================== 42.0.1 - 2024-11-21 =================== diff --git a/resolwe/flow/models/annotations.py b/resolwe/flow/models/annotations.py index 358df6d75..e80abd131 100644 --- a/resolwe/flow/models/annotations.py +++ b/resolwe/flow/models/annotations.py @@ -517,9 +517,9 @@ def delete_marker(self) -> bool: return self._value is None @property - def value(self) -> str | int | float | datetime.date: - """Get the actual value.""" - return self._value["value"] + def value(self) -> Optional[str | int | float | datetime.date]: + """Get the actual value or None if object is delete marker.""" + return None if self.delete_marker else self._value["value"] @value.setter def value(self, value: str | int | float | datetime.date): diff --git a/resolwe/flow/tests/test_annotations.py b/resolwe/flow/tests/test_annotations.py index 4c6bc7147..e9896f92c 100644 --- a/resolwe/flow/tests/test_annotations.py +++ b/resolwe/flow/tests/test_annotations.py @@ -1270,6 +1270,20 @@ def test_list_filter_values(self): self.assertTrue(response.data[0]["value"], "string") self.assertTrue(response.data[0]["label"], "label string") + # Test delete markers are handled properly. + delete_marker = AnnotationValue.objects.create( + entity=self.annotation_value1.entity, + field=self.annotation_value1.field, + _value=None, + contributor=self.annotation_value1.contributor, + ) + request = factory.get("/", {"entity": self.entity1.pk}, format="json") + force_authenticate(request, self.contributor) + response = self.annotationvalue_viewset(request) + self.assertTrue(response.status_code, status.HTTP_200_OK) + self.assertEqual(len(response.data), 0) + delete_marker.delete() + # Another authenticated request. self.annotation_value2.entity = self.entity1 self.annotation_value2.save()