Commit fb030dc
fix: lazily migrate non-UUID workflow ids to a fresh UUID (#11631)
*PR Created by the Glary-Bot Agent*
---
## Summary
Regenerate the top-level workflow `id` on load when it is present but
not a canonical UUID, so legacy slug ids from custom-node templates no
longer survive round-trip save/publish and break the cloud share
loader's zod validation.
## Changes
- **What**:
- Added `isValidUuid` helper in
`packages/shared-frontend-utils/src/formatUtil.ts`.
- Tightened `ensureWorkflowId` in `workflowStore.ts`: `!base.id` →
`!isValidUuid(base.id)`, so slug-shaped ids get replaced with a fresh
UUID, not just missing ones.
- Normalized non-UUID ids to `undefined` in the same-path reuse equality
check in `afterLoadNewGraph` so the first-load-rewrites,
second-load-reuses flow works and does not open a duplicate tab.
- Unit coverage for `isValidUuid`, for the new migration branch of
`createTemporary`, and two regression tests for the same-path reuse fix
(slug-to-UUID rewrite; both-sides-legacy-slug).
- **Breaking**: none. All missing-id cases still produce a UUID; valid
UUIDs still pass through unchanged. Only new behavior is replacing slug
ids instead of keeping them.
## Review Focus
- **Subgraph references are untouched.** Only the top-level
`workflow.id` is migrated. `zSubgraphDefinition.id` and the `node.type`
UUIDs that reference it are left alone, because subgraph-instance
containers reference their definitions by UUID and regenerating those
WOULD orphan instances. This migration is safe only for the outer id.
- **Same-path reuse normalization.** Initial review flagged that
rewriting the id on first load would break same-path reuse when the
second load arrives with the original slug.
`normalizeWorkflowIdForReuse` collapses non-UUID ids to `undefined` for
the equality check; regression tests cover both the mixed (slug vs fresh
UUID) and both-sides-slug cases.
- **Permissive UUID regex.** `isValidUuid` matches the canonical
8-4-4-4-12 hex form case-insensitively for any version/variant, not just
v4. Some historical workflows carry non-v4 UUIDs that were generated by
older code paths; accepting them avoids triggering another round of
re-migration that would orphan graph identity across saves.
## Background
Investigated in `#live-ops`: a publicly shared SAM3 workflow failed to
load with `Invalid uuid at "id"` because the workflow JSON had `"id":
"video-point-prompt-example"` — a slug carried over from
`PozzettiAndrea/ComfyUI-SAM3/workflows/video_point_prompt.json`. Today's
frontend enforces `z.string().uuid().optional()` on load via the cloud
share service, which throws when a legacy slug is present. See the
thread for full git-archaeology and subgraph-reference audit.
┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-11631-fix-lazily-migrate-non-UUID-workflow-ids-to-a-fresh-UUID-34d6d73d365081c79bc8e1d709e0c2f9)
by [Unito](https://www.unito.io)
---------
Co-authored-by: Glary-Bot <glary-bot@users.noreply.github.com>
Co-authored-by: Amp <amp@ampcode.com>1 parent 3f1950f commit fb030dc
9 files changed
Lines changed: 428 additions & 88 deletions
File tree
- src/platform/workflow
- core
- services
- utils
- management/stores
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| 19 | + | |
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
| |||
514 | 516 | | |
515 | 517 | | |
516 | 518 | | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
517 | 545 | | |
518 | 546 | | |
519 | 547 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
403 | 403 | | |
404 | 404 | | |
405 | 405 | | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
406 | 413 | | |
407 | 414 | | |
408 | 415 | | |
| |||
Lines changed: 114 additions & 41 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
65 | 70 | | |
66 | 71 | | |
67 | 72 | | |
| |||
591 | 596 | | |
592 | 597 | | |
593 | 598 | | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
594 | 602 | | |
595 | 603 | | |
596 | 604 | | |
| |||
603 | 611 | | |
604 | 612 | | |
605 | 613 | | |
606 | | - | |
607 | | - | |
| 614 | + | |
| 615 | + | |
608 | 616 | | |
609 | 617 | | |
610 | | - | |
611 | | - | |
612 | | - | |
613 | | - | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
614 | 622 | | |
615 | 623 | | |
616 | 624 | | |
| |||
622 | 630 | | |
623 | 631 | | |
624 | 632 | | |
625 | | - | |
626 | | - | |
627 | | - | |
| 633 | + | |
628 | 634 | | |
629 | 635 | | |
630 | 636 | | |
| |||
636 | 642 | | |
637 | 643 | | |
638 | 644 | | |
639 | | - | |
| 645 | + | |
| 646 | + | |
640 | 647 | | |
641 | | - | |
642 | | - | |
643 | | - | |
| 648 | + | |
644 | 649 | | |
645 | 650 | | |
646 | 651 | | |
| |||
649 | 654 | | |
650 | 655 | | |
651 | 656 | | |
652 | | - | |
653 | | - | |
654 | | - | |
655 | | - | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
656 | 661 | | |
657 | 662 | | |
658 | 663 | | |
| |||
661 | 666 | | |
662 | 667 | | |
663 | 668 | | |
664 | | - | |
| 669 | + | |
| 670 | + | |
665 | 671 | | |
666 | | - | |
667 | | - | |
668 | | - | |
669 | | - | |
670 | | - | |
671 | | - | |
672 | | - | |
673 | | - | |
674 | | - | |
675 | | - | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
676 | 676 | | |
677 | 677 | | |
678 | 678 | | |
| |||
687 | 687 | | |
688 | 688 | | |
689 | 689 | | |
690 | | - | |
| 690 | + | |
691 | 691 | | |
692 | 692 | | |
693 | 693 | | |
| |||
697 | 697 | | |
698 | 698 | | |
699 | 699 | | |
700 | | - | |
701 | | - | |
702 | | - | |
| 700 | + | |
703 | 701 | | |
704 | 702 | | |
705 | 703 | | |
706 | 704 | | |
707 | 705 | | |
708 | 706 | | |
709 | 707 | | |
710 | | - | |
711 | | - | |
712 | | - | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
713 | 712 | | |
714 | 713 | | |
715 | 714 | | |
| |||
719 | 718 | | |
720 | 719 | | |
721 | 720 | | |
722 | | - | |
723 | | - | |
724 | | - | |
| 721 | + | |
725 | 722 | | |
726 | 723 | | |
727 | 724 | | |
| |||
733 | 730 | | |
734 | 731 | | |
735 | 732 | | |
736 | | - | |
737 | | - | |
738 | | - | |
| 733 | + | |
739 | 734 | | |
740 | 735 | | |
741 | 736 | | |
742 | 737 | | |
743 | 738 | | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
744 | 817 | | |
745 | 818 | | |
746 | 819 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
13 | 18 | | |
14 | 19 | | |
15 | 20 | | |
| |||
493 | 498 | | |
494 | 499 | | |
495 | 500 | | |
| 501 | + | |
496 | 502 | | |
497 | 503 | | |
498 | 504 | | |
499 | | - | |
500 | | - | |
501 | | - | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
502 | 510 | | |
503 | 511 | | |
504 | 512 | | |
| |||
519 | 527 | | |
520 | 528 | | |
521 | 529 | | |
522 | | - | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
523 | 534 | | |
524 | 535 | | |
525 | 536 | | |
| |||
546 | 557 | | |
547 | 558 | | |
548 | 559 | | |
549 | | - | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
550 | 564 | | |
551 | 565 | | |
552 | 566 | | |
| |||
0 commit comments