fix(db,migrate): repair invalid workspace slugs (047), log why provision refuses its own answer - #414
Merged
Merged
Conversation
…-log-validation # Conflicts: # CHANGELOG.md
Member
Author
|
ONAY @ e4aa7f9 — ORK review: 047 repairs only slugs failing ^[a-z0-9][a-z0-9-]{0,62}$ (idempotent, collision suffix), handle_new_user lowercases before replace (managed pair fires the same trigger: managed-auth.ts:18/120); provision logs own-answer validation errors (no checkout URL logged). Merge of main resolved CHANGELOG only. CI ci+postgres-lineage green; local: 49 migrations on temp PG, contract 166, unit 2053. Fixes E2E B15 (covered provision 502). |
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.
What
Staging E2E:
POST /api/migrate/provisionanswered 502 for an account whose workspace slug is not one Migrate accepts, and logged nothing.handle_new_user()replaced[^a-z0-9-]with-and only then lowercased, so a GitHub name with capitals (ABB65) became---65-1a2b3c4d.@contentrain/typesvalidates the answer's slug against^[a-z0-9][a-z0-9-]{0,62}$, so Studio refused its own answer.047_workspace_slug_repair.sql.user.workspaceif empty). A collision gets the workspace id's first 8 characters, then a counter. A valid slug is never touched; a second run changes nothing.slugify.What a slug change can break
/w/<slug>and any email link already sent to it: changes for the repaired workspaces only. Accepted; they were unusable for Migrate anyway.workspace_id; the slug is only returned in the answer. Not affected.workspaces_slug_keyis kept by the collision handling.Deploy order
Managed pair: automatic, the Railway pre-deploy
node scripts/migrate-postgres.mjsapplies 047 before the image serves. Supabase pair:pnpm db:migratefirst. The old image works against 047. Numbering follows #413 (046); 047 applies fine with or without it.Evidence (local, throwaway Postgres 16)
scripts/migrate-postgres.mjs: 48 applied.ABB65,Jane.Doe_X,__getabb65-…,jane-doe-x-…,user-….---65-1a2b3c4d,ABC_def,Taken(collides withtaken),!!!, a 70-char slug and-taken-all become valid and unique; the validtakenstays; second run identical.workspace-slug.contract.test.ts; full contract suite 163 passed, 1 skipped.pnpm test:ci: unit 2039, integration 487, nuxt 274 green (one earlier unit run showed 4 failures in conversation-engine tests that did not repeat; unit re-run was clean).pnpm typecheckclean, eslint 0 errors.