Skip to content

Commit

Permalink
fix: don't allow spaces in workflow name
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgrittner committed Aug 25, 2024
1 parent 43f8663 commit 38a1651
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions admyral/server/endpoints/workflow_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@


MANUAL_TRIGGER_SOURCE_NAME = "manual"
SPACE = " "


class WorkflowBody(BaseModel):
Expand Down Expand Up @@ -61,6 +62,9 @@ async def push_workflow_impl(
admyral_store = get_admyral_store()
workers_client = get_workers_client()

if SPACE in workflow_name:
raise ValueError("Workflow name must not contain spaces.")

if workflow_id:
existing_workflow = await admyral_store.get_workflow_by_id(workflow_id)
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { useEffect } from "react";
import { errorToast, infoToast } from "@/lib/toast";
import { AxiosError } from "axios";

const SPACE = " ";

export default function SaveWorkflowButton() {
const { getWorkflow, updateWebhookIdAndSecret } = useWorkflowStore();
const saveWorkflow = useSaveWorkflowApi();
Expand Down Expand Up @@ -41,13 +43,16 @@ export default function SaveWorkflowButton() {

const handleSaveWorkflow = () => {
const workflow = getWorkflow();
// TODO(frontend): validate workflow name
if (workflow.workflowName.length === 0) {
errorToast(
"Workflow name must not be empty. Go to settings to set one.",
);
return;
}
if (workflow.workflowName.includes(SPACE)) {
errorToast("Workflow name must contain empty spaces.");
return;
}
saveWorkflow.mutate(workflow);
};

Expand Down

0 comments on commit 38a1651

Please sign in to comment.