fix(mockup): BUG-400 — resolve HTTP 400 in generated_mockups history query#570
Conversation
PostgREST returns HTTP 400 when any column in ?select= doesn't exist in
the table. fetchMockupHistory was requesting 9 columns that were never
added to generated_mockups:
- position_x, position_y, logo_width_cm, logo_height_cm → in area_config JSONB
- client_id, client_name, location_name, colors_count, annotations → in area_config JSONB
Fix: use .select('*') and remap area_config fields in a JS mapper.
The GeneratedMockup interface shape is preserved — consumers see the same
flat structure they expected.
…n't exist) Secondary fix: MockupHistoryPage search used client_name.ilike which causes a 400 because client_name is not a column on generated_mockups. Replaced with technique_name.ilike. Also: inline the area_config JSONB mapper in MockupHistoryPage so the component gets client_name, location_name, and logo dimensions correctly from the JSONB field without relying on fetchMockupHistory.
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
More reviews will be available in 51 minutes and 45 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 (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
1 issue found across 2 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="src/hooks/mockup/mockupGenerationService.ts">
<violation number="1" location="src/hooks/mockup/mockupGenerationService.ts:230">
P0: `generateMockupApi` now sends a payload schema that the `generate-mockup` edge function does not accept, causing validation 400s.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| } | ||
| const generateCall = supabase.functions.invoke('generate-mockup', { | ||
| body: { | ||
| productImage: params.productImage, |
There was a problem hiding this comment.
P0: generateMockupApi now sends a payload schema that the generate-mockup edge function does not accept, causing validation 400s.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/hooks/mockup/mockupGenerationService.ts, line 230:
<comment>`generateMockupApi` now sends a payload schema that the `generate-mockup` edge function does not accept, causing validation 400s.</comment>
<file context>
@@ -252,163 +213,46 @@ export interface GenerateMockupParams {
- }
+ const generateCall = supabase.functions.invoke('generate-mockup', {
+ body: {
+ productImage: params.productImage,
+ productName: params.productName,
+ technique: params.technique,
</file context>
Bug
Causa Raiz
PostgREST retorna HTTP 400 quando qualquer coluna no
?select=não existe na tabela.fetchMockupHistorysolicitava 9 colunas que nunca foram criadas emgenerated_mockups:position_x,position_yarea_configJSONBlogo_width_cm,logo_height_cmarea_configJSONBclient_name,colors_count,annotationsarea_configJSONBclient_idlocation_namearea_namena tabelaAdicionalmente,
MockupHistoryPageusavaclient_name.ilike.%search%num filtro.or()— também causando 400 pela mesma razão.Correções
mockupGenerationService.ts: Substituir select explícito porselect('*')e mapeararea_configJSONB no resultado. InterfaceGeneratedMockuppreservada — consumidores não percebem mudança.MockupHistoryPage.tsx:client_name.ilikedo filtro.or()→ substituído portechnique_name.ilikearea_configparaclient_name,location_name, dimensões da logoSummary by cubic
Fixes HTTP 400 errors in generated mockups history by selecting only real columns and mapping JSONB fields from
area_config. Also removes the invalidclient_namesearch filter to prevent 400s on the history page. (BUG-400)fetchMockupHistory: use.select('*')and maparea_configJSONB into the flatGeneratedMockupshape (position_x/y, logo_width_cm/height_cm, client_name, colors_count, annotations;location_namefromarea_name) to avoid selecting non-existent columns.MockupHistoryPage: removedclient_name.ilikefrom the.or()filter; replaced withtechnique_name.ilike. Added inlinearea_configmapper and updated the search placeholder.Written for commit ea882e9. Summary will update on new commits.