Skip to content

fix(useProductsColorsBatch): filter mock IDs to prevent Supabase 400#617

Merged
adm01-debug merged 1 commit into
mainfrom
fix/colors-batch-filter-mock-ids
Jun 2, 2026
Merged

fix(useProductsColorsBatch): filter mock IDs to prevent Supabase 400#617
adm01-debug merged 1 commit into
mainfrom
fix/colors-batch-filter-mock-ids

Conversation

@adm01-debug

@adm01-debug adm01-debug commented Jun 2, 2026

Copy link
Copy Markdown
Owner

Bug

SmartRecommendationsMock e useNovelties usam IDs placeholder (mock-1 a mock-5). Quando esses IDs fluem para useProductsColorsBatch, a query .in('product_id', ['mock-1', ...]) no Supabase retorna 400 porque a coluna product_id é UUID e mock-1 não é UUID válido.

Fix

Adicionar filtro UUID v4 no stableIds useMemo:

const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
const stableIds = useMemo(
  () => [...new Set(productIds)].filter((id) => UUID_RE.test(id)).sort(),
  [productIds],
);

IDs mock são silenciosamente descartados antes de tocar o Supabase.


Summary by cubic

Filter non-UUID placeholder IDs in useProductsColorsBatch to prevent Supabase .in('product_id', ...) 400 errors. Adds a UUID v4 check so mock IDs (e.g., "mock-1") are dropped before querying.

  • Bug Fixes
    • Stable key now keeps only deduped, sorted UUID v4 IDs; mock/placeholder IDs are ignored.
    • Stops 400s when SmartRecommendationsMock or useNovelties pass placeholder IDs; no change for valid products.

Written for commit b46852b. Summary will update on new commits.

Review in cubic

…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.
Copilot AI review requested due to automatic review settings June 2, 2026 21:46
@vercel

vercel Bot commented Jun 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
we-dream-big Error Error Jun 2, 2026 9:46pm

@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@adm01-debug, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 516ec132-a6ae-43c7-bbb6-7ccbbfbdfff6

📥 Commits

Reviewing files that changed from the base of the PR and between b1242a7 and b46852b.

📒 Files selected for processing (1)
  • src/hooks/products/useProductsColorsBatch.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/colors-batch-filter-mock-ids

Comment @coderabbitai help to get the list of available commands and usage tips.

@supabase

supabase Bot commented Jun 2, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project doufsxqlfjyuvxuezpln because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@adm01-debug adm01-debug merged commit e188d39 into main Jun 2, 2026
19 of 33 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_RE no módulo para validar formato de UUID e descartar IDs mock/placeholder.
  • Atualiza o stableIds para 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.

Comment on lines +27 to +31
/**
* 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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants