mirror of
https://github.com/langgenius/dify.git
synced 2026-04-21 03:07:39 +08:00
fix: workflow can not init
This commit is contained in:
@ -102,7 +102,10 @@ export const useNodesSyncDraft = () => {
|
||||
setDraftUpdatedAt,
|
||||
} = workflowStore.getState()
|
||||
try {
|
||||
const res = await syncWorkflowDraft(postParams)
|
||||
const res = await syncWorkflowDraft({
|
||||
...postParams,
|
||||
canNotSaveEmpty: true,
|
||||
})
|
||||
setSyncWorkflowDraftHash(res.hash)
|
||||
setDraftUpdatedAt(res.updated_at)
|
||||
callback?.onSuccess?.()
|
||||
|
||||
@ -107,7 +107,10 @@ export const useNodesSyncDraft = () => {
|
||||
setDraftUpdatedAt,
|
||||
} = workflowStore.getState()
|
||||
try {
|
||||
const res = await syncWorkflowDraft(postParams)
|
||||
const res = await syncWorkflowDraft({
|
||||
...postParams,
|
||||
canNotSaveEmpty: true,
|
||||
})
|
||||
setSyncWorkflowDraftHash(res.hash)
|
||||
setDraftUpdatedAt(res.updated_at)
|
||||
callback?.onSuccess?.()
|
||||
|
||||
@ -15,12 +15,13 @@ export const fetchWorkflowDraft = (url: string) => {
|
||||
return get(url, {}, { silent: true }) as Promise<FetchWorkflowDraftResponse>
|
||||
}
|
||||
|
||||
export const syncWorkflowDraft = ({ url, params }: {
|
||||
export const syncWorkflowDraft = ({ url, params, canNotSaveEmpty }: {
|
||||
url: string
|
||||
params: Pick<FetchWorkflowDraftResponse, 'graph' | 'features' | 'environment_variables' | 'conversation_variables'>
|
||||
canNotSaveEmpty?: boolean
|
||||
}) => {
|
||||
// when graph adn skill type changed, it would pass empty nodes array...Temp prevent sync in this case
|
||||
if (params.graph.nodes.length === 0) {
|
||||
if (params.graph.nodes.length === 0 && canNotSaveEmpty) {
|
||||
throw new Error('Cannot sync workflow draft with zero nodes.')
|
||||
}
|
||||
const sanitized = sanitizeWorkflowDraftPayload(params)
|
||||
|
||||
Reference in New Issue
Block a user