-
Notifications
You must be signed in to change notification settings - Fork 3.4k
fix: enable workflow validation before deployment (was hardcoded to false) #3579
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
1376793
70dd04d
30c68ae
d646ee1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -26,6 +26,7 @@ import { | |||||||||||||||||||||||||||||||||||||
| } from '@/components/emcn' | ||||||||||||||||||||||||||||||||||||||
| import { VariableIcon } from '@/components/icons' | ||||||||||||||||||||||||||||||||||||||
| import { generateWorkflowJson } from '@/lib/workflows/operations/import-export' | ||||||||||||||||||||||||||||||||||||||
| import { validateWorkflowState } from '@/lib/workflows/sanitization/validation' | ||||||||||||||||||||||||||||||||||||||
| import { useRegisterGlobalCommands } from '@/app/workspace/[workspaceId]/providers/global-commands-provider' | ||||||||||||||||||||||||||||||||||||||
| import { useUserPermissionsContext } from '@/app/workspace/[workspaceId]/providers/workspace-permissions-provider' | ||||||||||||||||||||||||||||||||||||||
| import { createCommands } from '@/app/workspace/[workspaceId]/utils/commands-utils' | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -356,7 +357,16 @@ export const Panel = memo(function Panel() { | |||||||||||||||||||||||||||||||||||||
| // Compute run button state | ||||||||||||||||||||||||||||||||||||||
| const canRun = userPermissions.canRead // Running only requires read permissions | ||||||||||||||||||||||||||||||||||||||
| const isLoadingPermissions = userPermissions.isLoading | ||||||||||||||||||||||||||||||||||||||
| const hasValidationErrors = false // TODO: Add validation logic if needed | ||||||||||||||||||||||||||||||||||||||
| const hasValidationErrors = useWorkflowStore((state) => { | ||||||||||||||||||||||||||||||||||||||
| if (Object.keys(state.blocks).length === 0) return false | ||||||||||||||||||||||||||||||||||||||
| const result = validateWorkflowState({ | ||||||||||||||||||||||||||||||||||||||
| blocks: state.blocks, | ||||||||||||||||||||||||||||||||||||||
| edges: state.edges, | ||||||||||||||||||||||||||||||||||||||
| loops: state.loops || {}, | ||||||||||||||||||||||||||||||||||||||
| parallels: state.parallels || {}, | ||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||
| return !result.valid | ||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+360
to
+369
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing
Suggested change
Comment on lines
+360
to
+369
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Expensive validation runs on every Zustand store update
Consider memoising outside the selector or debouncing: // Coarse selector — only re-validates when blocks/edges identity changes
const { blocks, edges, loops, parallels } = useWorkflowStore(
useShallow((state) => ({
blocks: state.blocks,
edges: state.edges,
loops: state.loops,
parallels: state.parallels,
}))
)
const hasValidationErrors = useMemo(() => {
if (Object.keys(blocks).length === 0) return false
return !validateWorkflowState({ blocks, edges, loops, parallels }).valid
}, [blocks, edges, loops, parallels])This keeps the computation lazy but avoids re-running it on unrelated store updates (e.g. execution state, cursor position). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Validation in selector mutates Zustand store stateMedium Severity Calling There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Expensive validation runs on every store updateMedium Severity
|
||||||||||||||||||||||||||||||||||||||
| const isWorkflowBlocked = isExecuting || hasValidationErrors | ||||||||||||||||||||||||||||||||||||||
| const isButtonDisabled = !isExecuting && (isWorkflowBlocked || (!canRun && !isLoadingPermissions)) | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing
loopsandparallelsblocks valid workflow deploymentsnormalizedDataalready containsloopsandparallels(used in theGEThandler on lines 83–86 of this same file), but they are omitted from thevalidateWorkflowStatecall here. The validation function usesworkflowState.loops || {}andworkflowState.parallels || {}, so passingundefinedmeans every edge whose source or target is a loop/parallel container will be flagged as referencing a non-existent block — causing the deployment to be rejected with a 400 even for a perfectly valid workflow.