fix(useProductsColorsBatch): filter mock IDs to prevent Supabase 400#617
Conversation
…base 400
SmartRecommendationsMock and useNovelties use placeholder IDs like
"mock-1" through "mock-5". When these flow into useProductsColorsBatch,
the `.in('product_id', chunk)` Supabase query returns 400 because the
IDs don't match the UUID column type.
Fix: Add UUID v4 regex filter in stableIds useMemo so non-UUID IDs
are silently dropped before reaching Supabase.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
More reviews will be available in 16 minutes and 56 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
There was a problem hiding this comment.
Pull request overview
Corrige um erro 400 do Supabase em useProductsColorsBatch quando IDs placeholder (ex.: mock-1) chegam na query .in('product_id', ...), filtrando previamente apenas IDs com formato de UUID antes de montar a chave estável e executar a consulta.
Changes:
- Adiciona
UUID_REno módulo para validar formato de UUID e descartar IDs mock/placeholder. - Atualiza o
stableIdspara deduplicar, filtrar por UUID e ordenar, evitando que IDs inválidos cheguem ao Supabase.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /** | ||
| * UUID v4 regex — filtra IDs mock/placeholder (ex: "mock-1") que causam | ||
| * erro 400 no Supabase quando enviados em queries `.in()`. | ||
| */ | ||
| const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i; |
Bug
SmartRecommendationsMockeuseNoveltiesusam IDs placeholder (mock-1amock-5). Quando esses IDs fluem parauseProductsColorsBatch, a query.in('product_id', ['mock-1', ...])no Supabase retorna 400 porque a colunaproduct_idé UUID emock-1não é UUID válido.Fix
Adicionar filtro UUID v4 no
stableIdsuseMemo:IDs mock são silenciosamente descartados antes de tocar o Supabase.
Summary by cubic
Filter non-UUID placeholder IDs in
useProductsColorsBatchto prevent Supabase.in('product_id', ...)400 errors. Adds a UUID v4 check so mock IDs (e.g., "mock-1") are dropped before querying.SmartRecommendationsMockoruseNoveltiespass placeholder IDs; no change for valid products.Written for commit b46852b. Summary will update on new commits.