Problem
Slug generation drops every non-[a-z0-9] character. For a name with no ASCII alphanumerics — non-Latin artist/stage names (e.g. サカナクション, Чайф) or punctuation-only input — the slug collapses to an empty string "".
This is a pre-existing issue, but the schedule-ingestion PR (#31) makes it newly fatal: the new artists_slug_unique constraint means two artists that both slugify to "" collide hard, and an empty slug also breaks slug-based .single() lookups (e.g. useSetBySlug).
Affected code
The same logic is duplicated in three places and any fix must keep them consistent:
src/lib/slug.ts — generateSlug
supabase/functions/diff-schedule/helpers.ts — toSlug
supabase/migrations/20260509142022_commit_schedule_rpc.sql — commit_schedule__slugify
Suggested fix
Guarantee a non-empty result. When the slug would be empty, fall back to a deterministic value derived from the original name (e.g. an md5(name)-based suffix/prefix) so the same name always produces the same slug across frontend, Edge, and SQL. Alternatively, broaden the allowed character set consistently in all three implementations.
Update — partial mitigation landed in #31
PR #31 now rejects artist/stage names with no [a-z0-9] at CSV parse time (parseScheduleCsv), with a clear message, so the empty-slug case can't reach the importer. This issue stays open for the proper cross-cutting fix (a guaranteed-non-empty slug) so other entry points — manual artist/stage creation — are covered too.
Related: distinct names colliding on one slug
Separate from empty slugs: two genuinely different names can slugify to the same value (e.g. "DJ Tennis" vs "DJ.Tennis"), silently linking them to one artist/stage. The same hash-fallback / disambiguation work should account for this case.
Context
Split out of PR #31 review (Copilot comments on helpers.ts toSlug and commit_schedule__slugify, plus the external review's slug-collision note). Deferred from that PR because the fix is cross-cutting and changes app-wide slug behavior beyond schedule import.
Problem
Slug generation drops every non-
[a-z0-9]character. For a name with no ASCII alphanumerics — non-Latin artist/stage names (e.g.サカナクション,Чайф) or punctuation-only input — the slug collapses to an empty string"".This is a pre-existing issue, but the schedule-ingestion PR (#31) makes it newly fatal: the new
artists_slug_uniqueconstraint means two artists that both slugify to""collide hard, and an empty slug also breaks slug-based.single()lookups (e.g.useSetBySlug).Affected code
The same logic is duplicated in three places and any fix must keep them consistent:
src/lib/slug.ts—generateSlugsupabase/functions/diff-schedule/helpers.ts—toSlugsupabase/migrations/20260509142022_commit_schedule_rpc.sql—commit_schedule__slugifySuggested fix
Guarantee a non-empty result. When the slug would be empty, fall back to a deterministic value derived from the original name (e.g. an
md5(name)-based suffix/prefix) so the same name always produces the same slug across frontend, Edge, and SQL. Alternatively, broaden the allowed character set consistently in all three implementations.Update — partial mitigation landed in #31
PR #31 now rejects artist/stage names with no
[a-z0-9]at CSV parse time (parseScheduleCsv), with a clear message, so the empty-slug case can't reach the importer. This issue stays open for the proper cross-cutting fix (a guaranteed-non-empty slug) so other entry points — manual artist/stage creation — are covered too.Related: distinct names colliding on one slug
Separate from empty slugs: two genuinely different names can slugify to the same value (e.g.
"DJ Tennis"vs"DJ.Tennis"), silently linking them to one artist/stage. The same hash-fallback / disambiguation work should account for this case.Context
Split out of PR #31 review (Copilot comments on
helpers.tstoSlugandcommit_schedule__slugify, plus the external review's slug-collision note). Deferred from that PR because the fix is cross-cutting and changes app-wide slug behavior beyond schedule import.