[dev] [Marfuen] mariano/fix-formtype-sync-hyphen-underscore#2658
Merged
Conversation
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>
1b522e8 to
91f4e08
Compare
Contributor
There was a problem hiding this comment.
1 issue found across 4 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/api/src/frameworks/framework-versioning/form-type-normalize.ts">
<violation number="1" location="apps/api/src/frameworks/framework-versioning/form-type-normalize.ts:18">
P2: This introduces substantial duplicate mapping logic; reuse the shared `EXTERNAL_TO_DB_EVIDENCE_FORM_TYPE` source to avoid drift and future form-type mismatches.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.
Contributor
|
🎉 This PR is included in version 3.32.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is an automated pull request to merge mariano/fix-formtype-sync-hyphen-underscore into dev.
It was created by the [Auto Pull Request] action.
Summary by cubic
Normalize EvidenceFormType from hyphenated DB labels to underscored Prisma enum names to fix sync 500s and avoid false diffs between backfilled v1.0.0 and newer manifests. Keeps diffs accurate and syncs stable without a data migration.
Written for commit adcf60b. Summary will update on new commits.