Commit 91f4e08
fix(frameworks): normalize EvidenceFormType in sync manifests
Sync to a newly-published framework version was 500ing on prod for any
customer whose instance was pinned to a backfilled v1.0.0. Root cause:
- EvidenceFormType has `@map` directives, so underscored Prisma enum
names (`infrastructure_inventory`) have hyphenated DB labels
(`infrastructure-inventory`).
- The one-shot backfill data migration serialized doc types via
`to_jsonb(ct."documentTypes"::text[])`, which renders the DB @Map'd
hyphen form. So every backfilled v1.0.0 manifest stored hyphens.
- The TS manifest builder reads `ct.documentTypes` from Prisma client,
which returns the underscored Prisma enum name. So CX-published
v2+ manifests store underscores.
- When a customer synced v1.0.0 -> v2, the diff treated every doc type
on every control as an add-underscore + remove-hyphen pair. The
remove path called `controlDocumentType.findUnique({ formType:
"infrastructure-inventory" })`; Prisma 7's strict enum validator
rejected the hyphen form and 500'd the whole sync transaction.
Fix normalizes to the Prisma-client (underscored) form:
- new form-type-normalize.ts maps hyphens -> underscores for every
@Map'd EvidenceFormType value
- framework-diff.sanitizeManifestEdges applies it before diffing, so
the diff doesn't spuriously report identical types as add+remove
- framework-sync-apply normalizes edge.formType before every Prisma
call (belt-and-suspenders)
- framework-rollback defensively normalizes stored undo payloads in
case an older sync persisted the raw hyphen value
Existing backfilled manifests don't need to be rewritten - they're
normalized at read time.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent cc7e756 commit 91f4e08
4 files changed
Lines changed: 45 additions & 5 deletions
File tree
- apps/api/src/frameworks/framework-versioning
Lines changed: 24 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
70 | 80 | | |
71 | 81 | | |
72 | 82 | | |
| |||
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
129 | 130 | | |
130 | 131 | | |
131 | 132 | | |
132 | | - | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
133 | 136 | | |
134 | 137 | | |
135 | 138 | | |
| |||
Lines changed: 7 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
325 | 326 | | |
326 | 327 | | |
327 | 328 | | |
| 329 | + | |
328 | 330 | | |
329 | 331 | | |
330 | | - | |
| 332 | + | |
331 | 333 | | |
332 | 334 | | |
333 | 335 | | |
334 | 336 | | |
335 | | - | |
| 337 | + | |
336 | 338 | | |
337 | 339 | | |
338 | 340 | | |
339 | 341 | | |
340 | 342 | | |
341 | 343 | | |
342 | 344 | | |
| 345 | + | |
343 | 346 | | |
344 | | - | |
| 347 | + | |
345 | 348 | | |
346 | 349 | | |
347 | 350 | | |
348 | 351 | | |
349 | | - | |
| 352 | + | |
350 | 353 | | |
351 | 354 | | |
352 | 355 | | |
| |||
0 commit comments