From 122afc0e91982f63d8165ec479288d9d776601ec Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20G=C3=B6bel?= <dgoebel@techfak.uni-bielefeld.de>
Date: Mon, 20 Mar 2023 15:40:32 +0100
Subject: [PATCH] Filter the prefix s3:// from the parameter
 report_output_bucket

#22
---
 app/api/utils.py                  | 4 +++-
 app/schemas/workflow_execution.py | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/app/api/utils.py b/app/api/utils.py
index 9f4ef51..7c80a76 100644
--- a/app/api/utils.py
+++ b/app/api/utils.py
@@ -197,7 +197,9 @@ async def check_buckets_access(
             errors.append(error)
     # Check if the user has access to the bucket where the report should be written
     if report_bucket is not None:
-        error = await _check_bucket_access(db, uid, report_bucket)
+        error = await _check_bucket_access(
+            db, uid, report_bucket[5:] if report_bucket.startswith("s3://") else report_bucket
+        )
         if error is not None:
             errors.append(error)
     if len(errors) > 0:
diff --git a/app/schemas/workflow_execution.py b/app/schemas/workflow_execution.py
index 92c380e..3c9ba61 100644
--- a/app/schemas/workflow_execution.py
+++ b/app/schemas/workflow_execution.py
@@ -27,7 +27,7 @@ class WorkflowExecutionIn(_BaseWorkflowExecution):
     parameters: dict[str, Any] = Field(..., description="Parameters for this workflow")
     report_output_bucket: str | None = Field(
         None,
-        description="Bucket where to save the Nextflow report. If None, no report will be generated",
+        description="Bucket where to save the Nextflow report. If None, no report will be generated. With our without prefix 's3://'",  # noqa: E501
         min_length=3,
         max_length=63,
         example="some-bucket",
-- 
GitLab