Skip to content
Merged
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
Update workflow object handling and validation
Refactor workflow object handling to allow undefined type and improve validation checks.
  • Loading branch information
r-vage authored Dec 4, 2025
commit 849bdc1570a00c4364701748b76be491a500ff1d
15 changes: 9 additions & 6 deletions src/scripts/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1441,26 +1441,29 @@ export class ComfyApp {
// Check workflow first - it should take priority over parameters
// when both are present (e.g., in ComfyUI-generated PNGs)
if (workflow) {
let workflowObj: ComfyWorkflowJSON
let workflowObj: ComfyWorkflowJSON | undefined
try {
workflowObj =
typeof workflow === 'string' ? JSON.parse(workflow) : workflow
} catch (err) {
console.error('Failed to parse workflow:', err)
this.showErrorOnFileLoad(file)
// Fall through to check parameters as fallback
}

// Validate workflow is a proper object
// Only load workflow if parsing succeeded AND validation passed
if (
typeof workflowObj !== 'object' ||
Array.isArray(workflowObj)
workflowObj &&
typeof workflowObj === 'object' &&
!Array.isArray(workflowObj)
) {
console.error('Invalid workflow structure')
} else {
await this.loadGraphData(workflowObj, true, true, fileName, {
openSource
})
return
} else if (workflowObj !== undefined) {
console.error('Invalid workflow structure, trying parameters fallback')
this.showErrorOnFileLoad(file)
}
}

Expand Down