Skip to content
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
ad92c12
fix: workflow page limit in serializer
athul-rs Aug 11, 2025
f70d076
UN-1720 [FIX] Improve workflow_id validation error message in Execute…
athul-rs Aug 11, 2025
9ed00a7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 11, 2025
c8e97f5
UN-1720 [FIX] Improve ExecuteWorkflowSerializer validations based on …
athul-rs Aug 11, 2025
249fa00
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 11, 2025
627ab60
UN-1720 [FIX] Address code review feedback for ExecuteWorkflowSerializer
athul-rs Aug 13, 2025
ca6d4d7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 13, 2025
17dc78f
Merge branch 'main' into UN-1720-Introducing-workflow-page-limit
athul-rs Aug 13, 2025
0733d01
UN-1720 [FEAT] Add frontend validation for workflow file upload limits
athul-rs Aug 13, 2025
1455465
UN-1720 [FIX] Add error code to file validation for better error hand…
athul-rs Aug 13, 2025
18edaa5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 13, 2025
e2b38fe
Builder error: prettier fix
athul-rs Aug 13, 2025
b019bda
Merge branch 'main' into UN-1720-Introducing-workflow-page-limit
athul-rs Aug 19, 2025
b611dd6
Merge branch 'main' into UN-1720-Introducing-workflow-page-limit
gaya3-zipstack Aug 22, 2025
fc18b30
Merge branch 'main' into UN-1720-Introducing-workflow-page-limit
gaya3-zipstack Aug 22, 2025
eac64fb
Merge branch 'main' into UN-1720-Introducing-workflow-page-limit
gaya3-zipstack Aug 22, 2025
372e1d6
Merge branch 'main' into UN-1720-Introducing-workflow-page-limit
athul-rs Aug 22, 2025
323faaf
refactor: Rename MAX_WORKFLOW_EXECUTION_FILES to WORKFLOW_PAGE_MAX_FILES
athul-rs Aug 22, 2025
ff1d202
fix: Refactor beforeUpload to avoid multiple identical returns
athul-rs Aug 22, 2025
a471cf9
Merge branch 'main' into UN-1720-Introducing-workflow-page-limit
athul-rs Aug 22, 2025
7f9943f
Merge branch 'main' into UN-1720-Introducing-workflow-page-limit
athul-rs Aug 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions backend/backend/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +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 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}"
Expand Down
2 changes: 2 additions & 0 deletions backend/sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +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 page execution
WORKFLOW_PAGE_MAX_FILES=2

# File execution tracker TTL in seconds (5 hours)
FILE_EXECUTION_TRACKER_TTL_IN_SECOND=18000
Expand Down
21 changes: 16 additions & 5 deletions backend/workflow_manager/workflow_v2/serializers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
from typing import Any

from django.conf import settings
from rest_framework.serializers import (
CharField,
ChoiceField,
Expand Down Expand Up @@ -65,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
)
Expand All @@ -86,10 +87,20 @@ 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("'workflow_id' 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) > settings.WORKFLOW_PAGE_MAX_FILES:
raise ValidationError(
{
"files": (
f"Maximum {settings.WORKFLOW_PAGE_MAX_FILES} files are allowed for workflow execution. "
f"You have uploaded '{len(files)}' files."
)
},
code="max_file_limit_exceeded",
)

return data

Expand Down
24 changes: 21 additions & 3 deletions frontend/src/components/agency/file-upload/FileUpload.jsx
Original file line number Diff line number Diff line change
@@ -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 {
WORKFLOW_PAGE_MAX_FILES,
WORKFLOW_VALIDATION_MESSAGES,
} from "./WfConstants.js";

const FileUpload = ({
open,
Expand All @@ -15,11 +19,23 @@ const FileUpload = ({
};

const beforeUpload = (file) => {
setFileList([...fileList, file]);
return false;
if (fileList.length >= WORKFLOW_PAGE_MAX_FILES) {
message.error(WORKFLOW_VALIDATION_MESSAGES.MAX_FILES_EXCEEDED);
} else {
setFileList([...fileList, file]);
}
return false; // Always prevent automatic upload (manual upload on submit)
};

const submitFile = () => {
if (fileList.length === 0) {
message.error(WORKFLOW_VALIDATION_MESSAGES.NO_FILES_SELECTED);
return;
}
if (fileList.length > WORKFLOW_PAGE_MAX_FILES) {
message.error(WORKFLOW_VALIDATION_MESSAGES.MAX_FILES_EXCEEDED);
return;
}
continueWfExecution(
wfExecutionParams[0],
wfExecutionParams[1],
Expand Down Expand Up @@ -47,6 +63,8 @@ const FileUpload = ({
fileList={fileList}
beforeUpload={beforeUpload}
onRemove={onRemove}
maxCount={WORKFLOW_PAGE_MAX_FILES}
multiple={true}
>
<Button icon={<UploadOutlined />}>Select File</Button>
</Upload>
Expand Down
13 changes: 13 additions & 0 deletions frontend/src/components/agency/file-upload/WfConstants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Workflow-related constants
*/

// 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 ${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.",
};