From ad92c12a694b8da16e5b519a9864c682b0ac2917 Mon Sep 17 00:00:00 2001 From: Athul Date: Mon, 11 Aug 2025 21:14:12 +0530 Subject: [PATCH 01/13] fix: workflow page limit in serializer --- backend/workflow_manager/workflow_v2/serializers.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/backend/workflow_manager/workflow_v2/serializers.py b/backend/workflow_manager/workflow_v2/serializers.py index 1ec9a559ac..f846f85c9a 100644 --- a/backend/workflow_manager/workflow_v2/serializers.py +++ b/backend/workflow_manager/workflow_v2/serializers.py @@ -91,6 +91,16 @@ def validate(self, data: dict[str, str | None]) -> dict[str, str | None]: if not workflow_id: raise ValidationError("'workflow_id' is required.") + # Validate file count from request context + request = self.context.get('request') + if request and hasattr(request, 'FILES'): + files = request.FILES.getlist('files') + if files and len(files) > 2: + raise ValidationError( + "Maximum 2 files are allowed for workflow execution. " + f"You have uploaded {len(files)} files." + ) + return data From f70d0763d159c22f256bfd9684dbd68e6b2a22b2 Mon Sep 17 00:00:00 2001 From: Athul Date: Tue, 12 Aug 2025 00:39:49 +0530 Subject: [PATCH 02/13] UN-1720 [FIX] Improve workflow_id validation error message in ExecuteWorkflowSerializer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changed validation error to use field-specific error dictionary format for better API response consistency when workflow_id is missing. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- backend/workflow_manager/workflow_v2/serializers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/workflow_manager/workflow_v2/serializers.py b/backend/workflow_manager/workflow_v2/serializers.py index f846f85c9a..711fb75a6c 100644 --- a/backend/workflow_manager/workflow_v2/serializers.py +++ b/backend/workflow_manager/workflow_v2/serializers.py @@ -89,7 +89,7 @@ def validate(self, data: dict[str, str | None]) -> dict[str, str | None]: workflow_id = data.get(WorkflowKey.WF_ID) if not workflow_id: - raise ValidationError("'workflow_id' is required.") + raise ValidationError({WorkflowKey.WF_ID: "This field is required."}) # Validate file count from request context request = self.context.get('request') From 9ed00a786c2de696cfd16ca348af998f72a5d176 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 11 Aug 2025 19:23:46 +0000 Subject: [PATCH 03/13] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- backend/workflow_manager/workflow_v2/serializers.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/workflow_manager/workflow_v2/serializers.py b/backend/workflow_manager/workflow_v2/serializers.py index 711fb75a6c..49cf8de3e1 100644 --- a/backend/workflow_manager/workflow_v2/serializers.py +++ b/backend/workflow_manager/workflow_v2/serializers.py @@ -92,9 +92,9 @@ def validate(self, data: dict[str, str | None]) -> dict[str, str | None]: raise ValidationError({WorkflowKey.WF_ID: "This field is required."}) # Validate file count from request context - request = self.context.get('request') - if request and hasattr(request, 'FILES'): - files = request.FILES.getlist('files') + request = self.context.get("request") + if request and hasattr(request, "FILES"): + files = request.FILES.getlist("files") if files and len(files) > 2: raise ValidationError( "Maximum 2 files are allowed for workflow execution. " From c8e97f50f8720f4b303709367cd723b75f25f584 Mon Sep 17 00:00:00 2001 From: Athul Date: Tue, 12 Aug 2025 00:54:43 +0530 Subject: [PATCH 04/13] UN-1720 [FIX] Improve ExecuteWorkflowSerializer validations based on code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Use RequestKey.REQUEST constant instead of string literal for consistency - Make file count validation error field-specific (similar to workflow_id) - Extract MAX_EXECUTION_FILES as a module constant for better maintainability - Improve error message structure for better API response consistency 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../workflow_manager/workflow_v2/serializers.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/backend/workflow_manager/workflow_v2/serializers.py b/backend/workflow_manager/workflow_v2/serializers.py index 49cf8de3e1..6fbe15eb83 100644 --- a/backend/workflow_manager/workflow_v2/serializers.py +++ b/backend/workflow_manager/workflow_v2/serializers.py @@ -23,6 +23,9 @@ logger = logging.getLogger(__name__) +# Maximum number of files allowed per workflow execution +MAX_EXECUTION_FILES = 2 + class WorkflowSerializer(IntegrityErrorMixin, AuditSerializer): tool_instances = ToolInstanceSerializer(many=True, read_only=True) @@ -92,14 +95,16 @@ def validate(self, data: dict[str, str | None]) -> dict[str, str | None]: raise ValidationError({WorkflowKey.WF_ID: "This field is required."}) # Validate file count from request context - request = self.context.get("request") + request = self.context.get(RequestKey.REQUEST) if request and hasattr(request, "FILES"): files = request.FILES.getlist("files") - if files and len(files) > 2: - raise ValidationError( - "Maximum 2 files are allowed for workflow execution. " - f"You have uploaded {len(files)} files." - ) + if len(files) > MAX_EXECUTION_FILES: + raise ValidationError({ + "files": ( + f"Maximum {MAX_EXECUTION_FILES} files are allowed for workflow execution. " + f"You have uploaded {len(files)} files." + ) + }) return data From 249fa0083edcca5a0474b0e13fa3ee4e95e11aaf Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 11 Aug 2025 19:38:37 +0000 Subject: [PATCH 05/13] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../workflow_manager/workflow_v2/serializers.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/backend/workflow_manager/workflow_v2/serializers.py b/backend/workflow_manager/workflow_v2/serializers.py index 6fbe15eb83..04939f335c 100644 --- a/backend/workflow_manager/workflow_v2/serializers.py +++ b/backend/workflow_manager/workflow_v2/serializers.py @@ -99,12 +99,14 @@ def validate(self, data: dict[str, str | None]) -> dict[str, str | None]: if request and hasattr(request, "FILES"): files = request.FILES.getlist("files") if len(files) > MAX_EXECUTION_FILES: - raise ValidationError({ - "files": ( - f"Maximum {MAX_EXECUTION_FILES} files are allowed for workflow execution. " - f"You have uploaded {len(files)} files." - ) - }) + raise ValidationError( + { + "files": ( + f"Maximum {MAX_EXECUTION_FILES} files are allowed for workflow execution. " + f"You have uploaded {len(files)} files." + ) + } + ) return data From 627ab60b7896b6dee4c8b00c14fe9522dbdcc0f5 Mon Sep 17 00:00:00 2001 From: Athul Date: Wed, 13 Aug 2025 12:02:19 +0530 Subject: [PATCH 06/13] UN-1720 [FIX] Address code review feedback for ExecuteWorkflowSerializer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Moved MAX_EXECUTION_FILES to Django settings as MAX_WORKFLOW_EXECUTION_FILES - Changed workflow_id field to required=True and removed redundant validation - Fixed error message formatting by adding quotes around file count - Added environment variable documentation in sample.env 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- backend/backend/settings/base.py | 4 +++ backend/sample.env | 2 ++ .../workflow_v2/serializers.py | 27 +++++++------------ 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/backend/backend/settings/base.py b/backend/backend/settings/base.py index 871f1c3fc2..446d3fcb9c 100644 --- a/backend/backend/settings/base.py +++ b/backend/backend/settings/base.py @@ -66,6 +66,10 @@ def get_required_setting(setting_key: str, default: str | None = None) -> str | WORKFLOW_ACTION_EXPIRATION_TIME_IN_SECOND = os.environ.get( "WORKFLOW_ACTION_EXPIRATION_TIME_IN_SECOND", 10800 ) +# Maximum number of files allowed per workflow execution +MAX_WORKFLOW_EXECUTION_FILES = int( + os.environ.get("MAX_WORKFLOW_EXECUTION_FILES", 2) +) WEB_APP_ORIGIN_URL = os.environ.get("WEB_APP_ORIGIN_URL", "http://localhost:3000") parsed_url = urlparse(WEB_APP_ORIGIN_URL) WEB_APP_ORIGIN_URL_WITH_WILD_CARD = f"{parsed_url.scheme}://*.{parsed_url.netloc}" diff --git a/backend/sample.env b/backend/sample.env index 1e0076cd4f..8d917db50a 100644 --- a/backend/sample.env +++ b/backend/sample.env @@ -180,6 +180,8 @@ INSTANT_WF_POLLING_TIMEOUT=300 MAX_PARALLEL_FILE_BATCHES=1 # Maximum allowed value for MAX_PARALLEL_FILE_BATCHES (upper limit for validation) MAX_PARALLEL_FILE_BATCHES_MAX_VALUE=100 +# Maximum number of files allowed per workflow execution +MAX_WORKFLOW_EXECUTION_FILES=2 # File execution tracker TTL in seconds (5 hours) FILE_EXECUTION_TRACKER_TTL_IN_SECOND=18000 diff --git a/backend/workflow_manager/workflow_v2/serializers.py b/backend/workflow_manager/workflow_v2/serializers.py index 04939f335c..828caacbfd 100644 --- a/backend/workflow_manager/workflow_v2/serializers.py +++ b/backend/workflow_manager/workflow_v2/serializers.py @@ -1,6 +1,7 @@ import logging from typing import Any +from django.conf import settings from rest_framework.serializers import ( CharField, ChoiceField, @@ -23,9 +24,6 @@ logger = logging.getLogger(__name__) -# Maximum number of files allowed per workflow execution -MAX_EXECUTION_FILES = 2 - class WorkflowSerializer(IntegrityErrorMixin, AuditSerializer): tool_instances = ToolInstanceSerializer(many=True, read_only=True) @@ -68,7 +66,7 @@ def create(self, validated_data: dict[str, Any]) -> Any: class ExecuteWorkflowSerializer(Serializer): - workflow_id = UUIDField(required=False) + workflow_id = UUIDField(required=True) execution_action = ChoiceField( choices=Workflow.ExecutionAction.choices, required=False ) @@ -89,24 +87,17 @@ def get_execution_action(self, validated_data: dict[str, str | None]) -> str | N return validated_data.get(WorkflowKey.EXECUTION_ACTION) def validate(self, data: dict[str, str | None]) -> dict[str, str | None]: - workflow_id = data.get(WorkflowKey.WF_ID) - - if not workflow_id: - raise ValidationError({WorkflowKey.WF_ID: "This field is required."}) - # Validate file count from request context request = self.context.get(RequestKey.REQUEST) if request and hasattr(request, "FILES"): files = request.FILES.getlist("files") - if len(files) > MAX_EXECUTION_FILES: - raise ValidationError( - { - "files": ( - f"Maximum {MAX_EXECUTION_FILES} files are allowed for workflow execution. " - f"You have uploaded {len(files)} files." - ) - } - ) + if len(files) > settings.MAX_WORKFLOW_EXECUTION_FILES: + raise ValidationError({ + "files": ( + f"Maximum {settings.MAX_WORKFLOW_EXECUTION_FILES} files are allowed for workflow execution. " + f"You have uploaded '{len(files)}' files." + ) + }) return data From ca6d4d7a34ecd67be45bbc2810d9888351bbaf84 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 13 Aug 2025 06:50:25 +0000 Subject: [PATCH 07/13] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- backend/backend/settings/base.py | 4 +--- .../workflow_manager/workflow_v2/serializers.py | 14 ++++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/backend/backend/settings/base.py b/backend/backend/settings/base.py index 446d3fcb9c..d5262781a2 100644 --- a/backend/backend/settings/base.py +++ b/backend/backend/settings/base.py @@ -67,9 +67,7 @@ def get_required_setting(setting_key: str, default: str | None = None) -> str | "WORKFLOW_ACTION_EXPIRATION_TIME_IN_SECOND", 10800 ) # Maximum number of files allowed per workflow execution -MAX_WORKFLOW_EXECUTION_FILES = int( - os.environ.get("MAX_WORKFLOW_EXECUTION_FILES", 2) -) +MAX_WORKFLOW_EXECUTION_FILES = int(os.environ.get("MAX_WORKFLOW_EXECUTION_FILES", 2)) WEB_APP_ORIGIN_URL = os.environ.get("WEB_APP_ORIGIN_URL", "http://localhost:3000") parsed_url = urlparse(WEB_APP_ORIGIN_URL) WEB_APP_ORIGIN_URL_WITH_WILD_CARD = f"{parsed_url.scheme}://*.{parsed_url.netloc}" diff --git a/backend/workflow_manager/workflow_v2/serializers.py b/backend/workflow_manager/workflow_v2/serializers.py index 828caacbfd..7247dce500 100644 --- a/backend/workflow_manager/workflow_v2/serializers.py +++ b/backend/workflow_manager/workflow_v2/serializers.py @@ -92,12 +92,14 @@ def validate(self, data: dict[str, str | None]) -> dict[str, str | None]: if request and hasattr(request, "FILES"): files = request.FILES.getlist("files") if len(files) > settings.MAX_WORKFLOW_EXECUTION_FILES: - raise ValidationError({ - "files": ( - f"Maximum {settings.MAX_WORKFLOW_EXECUTION_FILES} files are allowed for workflow execution. " - f"You have uploaded '{len(files)}' files." - ) - }) + raise ValidationError( + { + "files": ( + f"Maximum {settings.MAX_WORKFLOW_EXECUTION_FILES} files are allowed for workflow execution. " + f"You have uploaded '{len(files)}' files." + ) + } + ) return data From 0733d0125d286d081a0d07175f630e9e03370bb9 Mon Sep 17 00:00:00 2001 From: Athul Date: Wed, 13 Aug 2025 13:24:54 +0530 Subject: [PATCH 08/13] UN-1720 [FEAT] Add frontend validation for workflow file upload limits MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Created WfConstants.js with MAX_WORKFLOW_EXECUTION_FILES constant - Updated FileUpload component to validate max 2 files before submission - Added client-side validation with proper error messages - Enhanced Upload component with maxCount and multiple file support - Improved user experience with immediate validation feedback 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../agency/file-upload/FileUpload.jsx | 20 ++++++++++++++++++- .../agency/file-upload/WfConstants.js | 13 ++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 frontend/src/components/agency/file-upload/WfConstants.js diff --git a/frontend/src/components/agency/file-upload/FileUpload.jsx b/frontend/src/components/agency/file-upload/FileUpload.jsx index 7bbb3ca5c1..2b63771cfe 100644 --- a/frontend/src/components/agency/file-upload/FileUpload.jsx +++ b/frontend/src/components/agency/file-upload/FileUpload.jsx @@ -1,6 +1,10 @@ import PropTypes from "prop-types"; -import { Modal, Upload, Button } from "antd"; +import { Modal, Upload, Button, message } from "antd"; import { UploadOutlined } from "@ant-design/icons"; +import { + MAX_WORKFLOW_EXECUTION_FILES, + WORKFLOW_VALIDATION_MESSAGES +} from "./WfConstants.js"; const FileUpload = ({ open, @@ -15,11 +19,23 @@ const FileUpload = ({ }; const beforeUpload = (file) => { + if (fileList.length >= MAX_WORKFLOW_EXECUTION_FILES) { + message.error(WORKFLOW_VALIDATION_MESSAGES.MAX_FILES_EXCEEDED); + return false; + } setFileList([...fileList, file]); return false; }; const submitFile = () => { + if (fileList.length === 0) { + message.error(WORKFLOW_VALIDATION_MESSAGES.NO_FILES_SELECTED); + return; + } + if (fileList.length > MAX_WORKFLOW_EXECUTION_FILES) { + message.error(WORKFLOW_VALIDATION_MESSAGES.MAX_FILES_EXCEEDED); + return; + } continueWfExecution( wfExecutionParams[0], wfExecutionParams[1], @@ -47,6 +63,8 @@ const FileUpload = ({ fileList={fileList} beforeUpload={beforeUpload} onRemove={onRemove} + maxCount={MAX_WORKFLOW_EXECUTION_FILES} + multiple={true} > diff --git a/frontend/src/components/agency/file-upload/WfConstants.js b/frontend/src/components/agency/file-upload/WfConstants.js new file mode 100644 index 0000000000..4028760c7a --- /dev/null +++ b/frontend/src/components/agency/file-upload/WfConstants.js @@ -0,0 +1,13 @@ +/** + * Workflow-related constants + */ + +// Maximum number of files allowed per workflow execution +export const MAX_WORKFLOW_EXECUTION_FILES = 2; + +// Error messages for workflow validation +export const WORKFLOW_VALIDATION_MESSAGES = { + MAX_FILES_EXCEEDED: `Maximum ${MAX_WORKFLOW_EXECUTION_FILES} files are allowed for workflow execution.`, + NO_FILES_SELECTED: "Please select at least one file to proceed.", + WORKFLOW_ID_REQUIRED: "Workflow ID is required for execution.", +}; \ No newline at end of file From 1455465ce8809f135d7690bfe88a5b64182ae1b8 Mon Sep 17 00:00:00 2001 From: Athul Date: Wed, 13 Aug 2025 13:27:04 +0530 Subject: [PATCH 09/13] UN-1720 [FIX] Add error code to file validation for better error handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added 'max_file_limit_exceeded' error code to ValidationError in ExecuteWorkflowSerializer to improve frontend error handling and API response consistency. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- backend/workflow_manager/workflow_v2/serializers.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/workflow_manager/workflow_v2/serializers.py b/backend/workflow_manager/workflow_v2/serializers.py index 7247dce500..0e0b9bbef0 100644 --- a/backend/workflow_manager/workflow_v2/serializers.py +++ b/backend/workflow_manager/workflow_v2/serializers.py @@ -98,7 +98,8 @@ def validate(self, data: dict[str, str | None]) -> dict[str, str | None]: f"Maximum {settings.MAX_WORKFLOW_EXECUTION_FILES} files are allowed for workflow execution. " f"You have uploaded '{len(files)}' files." ) - } + }, + code="max_file_limit_exceeded", ) return data From 18edaa51254289129b1aa2265888a8d661390626 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 13 Aug 2025 07:58:27 +0000 Subject: [PATCH 10/13] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- frontend/src/components/agency/file-upload/FileUpload.jsx | 6 +++--- frontend/src/components/agency/file-upload/WfConstants.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/agency/file-upload/FileUpload.jsx b/frontend/src/components/agency/file-upload/FileUpload.jsx index 2b63771cfe..a29db34be2 100644 --- a/frontend/src/components/agency/file-upload/FileUpload.jsx +++ b/frontend/src/components/agency/file-upload/FileUpload.jsx @@ -1,9 +1,9 @@ import PropTypes from "prop-types"; import { Modal, Upload, Button, message } from "antd"; import { UploadOutlined } from "@ant-design/icons"; -import { - MAX_WORKFLOW_EXECUTION_FILES, - WORKFLOW_VALIDATION_MESSAGES +import { + MAX_WORKFLOW_EXECUTION_FILES, + WORKFLOW_VALIDATION_MESSAGES } from "./WfConstants.js"; const FileUpload = ({ diff --git a/frontend/src/components/agency/file-upload/WfConstants.js b/frontend/src/components/agency/file-upload/WfConstants.js index 4028760c7a..31fadd33fe 100644 --- a/frontend/src/components/agency/file-upload/WfConstants.js +++ b/frontend/src/components/agency/file-upload/WfConstants.js @@ -10,4 +10,4 @@ export const WORKFLOW_VALIDATION_MESSAGES = { MAX_FILES_EXCEEDED: `Maximum ${MAX_WORKFLOW_EXECUTION_FILES} files are allowed for workflow execution.`, NO_FILES_SELECTED: "Please select at least one file to proceed.", WORKFLOW_ID_REQUIRED: "Workflow ID is required for execution.", -}; \ No newline at end of file +}; From e2b38fe3813dc32d98f04ea12b4c89122d2cb7df Mon Sep 17 00:00:00 2001 From: Athul Date: Wed, 13 Aug 2025 13:52:36 +0530 Subject: [PATCH 11/13] Builder error: prettier fix --- frontend/src/components/agency/file-upload/FileUpload.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/agency/file-upload/FileUpload.jsx b/frontend/src/components/agency/file-upload/FileUpload.jsx index a29db34be2..0decd1c8f6 100644 --- a/frontend/src/components/agency/file-upload/FileUpload.jsx +++ b/frontend/src/components/agency/file-upload/FileUpload.jsx @@ -3,7 +3,7 @@ import { Modal, Upload, Button, message } from "antd"; import { UploadOutlined } from "@ant-design/icons"; import { MAX_WORKFLOW_EXECUTION_FILES, - WORKFLOW_VALIDATION_MESSAGES + WORKFLOW_VALIDATION_MESSAGES, } from "./WfConstants.js"; const FileUpload = ({ From 323faafeba02bd62ca5f4eb91302c4c4ff6404b5 Mon Sep 17 00:00:00 2001 From: Athul Date: Fri, 22 Aug 2025 13:29:55 +0530 Subject: [PATCH 12/13] refactor: Rename MAX_WORKFLOW_EXECUTION_FILES to WORKFLOW_PAGE_MAX_FILES MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Renamed setting to better indicate it's specific to workflow page functionality - Updated backend settings, environment variables, and serializer - Updated frontend constants and all references in FileUpload component - Maintains same functionality with clearer naming convention 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- backend/backend/settings/base.py | 4 ++-- backend/sample.env | 4 ++-- backend/workflow_manager/workflow_v2/serializers.py | 4 ++-- frontend/src/components/agency/file-upload/FileUpload.jsx | 8 ++++---- frontend/src/components/agency/file-upload/WfConstants.js | 6 +++--- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/backend/backend/settings/base.py b/backend/backend/settings/base.py index 4c71a75842..8ac0c26714 100644 --- a/backend/backend/settings/base.py +++ b/backend/backend/settings/base.py @@ -66,8 +66,8 @@ def get_required_setting(setting_key: str, default: str | None = None) -> str | WORKFLOW_ACTION_EXPIRATION_TIME_IN_SECOND = os.environ.get( "WORKFLOW_ACTION_EXPIRATION_TIME_IN_SECOND", 10800 ) -# Maximum number of files allowed per workflow execution -MAX_WORKFLOW_EXECUTION_FILES = int(os.environ.get("MAX_WORKFLOW_EXECUTION_FILES", 2)) +# Maximum number of files allowed per workflow page execution +WORKFLOW_PAGE_MAX_FILES = int(os.environ.get("WORKFLOW_PAGE_MAX_FILES", 2)) WEB_APP_ORIGIN_URL = os.environ.get("WEB_APP_ORIGIN_URL", "http://localhost:3000") parsed_url = urlparse(WEB_APP_ORIGIN_URL) WEB_APP_ORIGIN_URL_WITH_WILD_CARD = f"{parsed_url.scheme}://*.{parsed_url.netloc}" diff --git a/backend/sample.env b/backend/sample.env index dd790e644f..ff59a75a0f 100644 --- a/backend/sample.env +++ b/backend/sample.env @@ -183,8 +183,8 @@ INSTANT_WF_POLLING_TIMEOUT=300 MAX_PARALLEL_FILE_BATCHES=1 # Maximum allowed value for MAX_PARALLEL_FILE_BATCHES (upper limit for validation) MAX_PARALLEL_FILE_BATCHES_MAX_VALUE=100 -# Maximum number of files allowed per workflow execution -MAX_WORKFLOW_EXECUTION_FILES=2 +# Maximum number of files allowed per workflow page execution +WORKFLOW_PAGE_MAX_FILES=2 # File execution tracker TTL in seconds (5 hours) FILE_EXECUTION_TRACKER_TTL_IN_SECOND=18000 diff --git a/backend/workflow_manager/workflow_v2/serializers.py b/backend/workflow_manager/workflow_v2/serializers.py index 0e0b9bbef0..e5f2b6817b 100644 --- a/backend/workflow_manager/workflow_v2/serializers.py +++ b/backend/workflow_manager/workflow_v2/serializers.py @@ -91,11 +91,11 @@ def validate(self, data: dict[str, str | None]) -> dict[str, str | None]: request = self.context.get(RequestKey.REQUEST) if request and hasattr(request, "FILES"): files = request.FILES.getlist("files") - if len(files) > settings.MAX_WORKFLOW_EXECUTION_FILES: + if len(files) > settings.WORKFLOW_PAGE_MAX_FILES: raise ValidationError( { "files": ( - f"Maximum {settings.MAX_WORKFLOW_EXECUTION_FILES} files are allowed for workflow execution. " + f"Maximum {settings.WORKFLOW_PAGE_MAX_FILES} files are allowed for workflow execution. " f"You have uploaded '{len(files)}' files." ) }, diff --git a/frontend/src/components/agency/file-upload/FileUpload.jsx b/frontend/src/components/agency/file-upload/FileUpload.jsx index 0decd1c8f6..1c73fd4c1f 100644 --- a/frontend/src/components/agency/file-upload/FileUpload.jsx +++ b/frontend/src/components/agency/file-upload/FileUpload.jsx @@ -2,7 +2,7 @@ import PropTypes from "prop-types"; import { Modal, Upload, Button, message } from "antd"; import { UploadOutlined } from "@ant-design/icons"; import { - MAX_WORKFLOW_EXECUTION_FILES, + WORKFLOW_PAGE_MAX_FILES, WORKFLOW_VALIDATION_MESSAGES, } from "./WfConstants.js"; @@ -19,7 +19,7 @@ const FileUpload = ({ }; const beforeUpload = (file) => { - if (fileList.length >= MAX_WORKFLOW_EXECUTION_FILES) { + if (fileList.length >= WORKFLOW_PAGE_MAX_FILES) { message.error(WORKFLOW_VALIDATION_MESSAGES.MAX_FILES_EXCEEDED); return false; } @@ -32,7 +32,7 @@ const FileUpload = ({ message.error(WORKFLOW_VALIDATION_MESSAGES.NO_FILES_SELECTED); return; } - if (fileList.length > MAX_WORKFLOW_EXECUTION_FILES) { + if (fileList.length > WORKFLOW_PAGE_MAX_FILES) { message.error(WORKFLOW_VALIDATION_MESSAGES.MAX_FILES_EXCEEDED); return; } @@ -63,7 +63,7 @@ const FileUpload = ({ fileList={fileList} beforeUpload={beforeUpload} onRemove={onRemove} - maxCount={MAX_WORKFLOW_EXECUTION_FILES} + maxCount={WORKFLOW_PAGE_MAX_FILES} multiple={true} > diff --git a/frontend/src/components/agency/file-upload/WfConstants.js b/frontend/src/components/agency/file-upload/WfConstants.js index 31fadd33fe..579bc225e3 100644 --- a/frontend/src/components/agency/file-upload/WfConstants.js +++ b/frontend/src/components/agency/file-upload/WfConstants.js @@ -2,12 +2,12 @@ * Workflow-related constants */ -// Maximum number of files allowed per workflow execution -export const MAX_WORKFLOW_EXECUTION_FILES = 2; +// Maximum number of files allowed per workflow page execution +export const WORKFLOW_PAGE_MAX_FILES = 2; // Error messages for workflow validation export const WORKFLOW_VALIDATION_MESSAGES = { - MAX_FILES_EXCEEDED: `Maximum ${MAX_WORKFLOW_EXECUTION_FILES} files are allowed for workflow execution.`, + MAX_FILES_EXCEEDED: `Maximum ${WORKFLOW_PAGE_MAX_FILES} files are allowed for workflow execution.`, NO_FILES_SELECTED: "Please select at least one file to proceed.", WORKFLOW_ID_REQUIRED: "Workflow ID is required for execution.", }; From ff1d20299b2615b3ff6102609c0d4cf031e51a80 Mon Sep 17 00:00:00 2001 From: Athul Date: Fri, 22 Aug 2025 15:01:34 +0530 Subject: [PATCH 13/13] fix: Refactor beforeUpload to avoid multiple identical returns MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Consolidated multiple return false statements into single return - Added comment explaining why false is always returned (manual upload) - Resolves SonarQube code smell about functions with duplicate returns 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- frontend/src/components/agency/file-upload/FileUpload.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/agency/file-upload/FileUpload.jsx b/frontend/src/components/agency/file-upload/FileUpload.jsx index 1c73fd4c1f..3709e1c7ba 100644 --- a/frontend/src/components/agency/file-upload/FileUpload.jsx +++ b/frontend/src/components/agency/file-upload/FileUpload.jsx @@ -21,10 +21,10 @@ const FileUpload = ({ const beforeUpload = (file) => { if (fileList.length >= WORKFLOW_PAGE_MAX_FILES) { message.error(WORKFLOW_VALIDATION_MESSAGES.MAX_FILES_EXCEEDED); - return false; + } else { + setFileList([...fileList, file]); } - setFileList([...fileList, file]); - return false; + return false; // Always prevent automatic upload (manual upload on submit) }; const submitFile = () => {