From c0b7882874bb21f8437e9ab8648b0cd0f982484a Mon Sep 17 00:00:00 2001 From: tdruez Date: Fri, 1 Nov 2024 13:21:26 +0400 Subject: [PATCH] Add proper pipeline validation in the OrderedMultiplePipelineChoiceField #1426 Signed-off-by: tdruez --- scanpipe/api/serializers.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scanpipe/api/serializers.py b/scanpipe/api/serializers.py index c2cd90efa..b7c671ec8 100644 --- a/scanpipe/api/serializers.py +++ b/scanpipe/api/serializers.py @@ -86,6 +86,14 @@ def to_internal_value(self, data): # Adds support for providing pipeline names as a comma-separated single string. data = [item.strip() for value in data for item in value.split(",")] + + # Pipeline validation + for pipeline in data: + pipeline_name, _ = scanpipe_app.extract_group_from_pipeline(pipeline) + pipeline_name = scanpipe_app.get_new_pipeline_name(pipeline_name) + if pipeline_name not in scanpipe_app.pipelines: + self.fail("invalid_choice", input=pipeline_name) + return data def to_representation(self, value):