-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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 1 commit
1376793
70dd04d
30c68ae
d646ee1
945b207
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
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,14 @@ 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, | ||
| }) | ||
| return !result.valid | ||
| }) | ||
|
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).
cursor[bot] marked this conversation as resolved.
Outdated
cursor[bot] marked this conversation as resolved.
Outdated
|
||
| 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
loopsandparallelscauses false-positive validation errorsvalidateWorkflowStatechecks edges against loop and parallel container IDs (lines 270–292 ofvalidation.ts). Becausestate.loopsandstate.parallelsare not passed here, any workflow that uses a loop or parallel block will have all edges connected to those containers reported as referencing "non-existent" source/target blocks — causinghasValidationErrorsto betruefor valid workflows and permanently disabling the Run button.