Comfy-Org / Comfy-Org/ComfyUI_frontend
Add runtime type guard or comment for graph.serialize() → MissingModelWorkflowData assignment in missingModelPipeline.ts
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 699
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 490
Description
## Summary
In `src/platform/missingModel/missingModelPipeline.ts`, `graph.serialize()` is assigned directly to `MissingModelWorkflowData` with no runtime guarantee that `LGraph.serialize()` actually satisfies the structural contract:
```ts
const graphData: MissingModelWorkflowData = graph.serialize()
```
The compiler accepts this because `MissingModelWorkflowData` (`FlattenableWorkflowGraph` + optional `models`) is intentionally minimal, but a reader must trust that LiteGraph emits `nodes` / `definitions.subgraphs` in the right shape at runtime. A one-line comment explaining the assumption, or a lightweight Zod/type-guard check, would make the contract explicit and prevent silent breakage if the LiteGraph serialization format changes.
## Suggested approaches
1. **Comment** — add an inline comment explaining why the direct assignment is safe (e.g., LiteGraph always emits `nodes: NodeLike[]` and optionally `definitions.subgraphs`).
2. **Type guard / narrow assertion** — introduce a minimal `isFlattenableWorkflowGraph` check and throw or warn if the contract is violated.
## Context
- PR: Comfy-Org/ComfyUI_frontend#11751
- Review comment: https://github.com/Comfy-Org/ComfyUI_frontend/pull/11751#discussion_r3171298822
- File: `src/platform/missingModel/missingModelPipeline.ts`
- Raised by: @DrJKL; tracking requested by: @jaeone94
┆Issue is synchronized with this [Notion page](https://app.notion.com/p/Issue-11795-Add-runtime-type-guard-or-comment-for-graph-serialize-MissingModelWorkflowData-as-3536d73d3650810496b6d78e7a26cdb8) by [Unito](https://www.unito.io)
Contributor guide
Assessment
This issue has not been assessed yet.