Silent data loss: user messages were never persisted due to a nonexistent column

Every user message in nwhitehouse's fork was silently dropped on write. The insert referenced a `workflow` column that doesn't exist in the schema; Supabase returned PGRST204 and the app never checked the result.

chat-uiinfrastructure

The bug is in both POST /chat and POST /projects/:id/chat. Both builds the insert payload with a workflow field that isn't in the chat_messages schema. Supabase's PostgREST returns PGRST204 - "no content matched" - when an unknown column is included, and silently rejects the entire row. Neither route checked error on the response.

Live sessions appeared correct because ChatView keeps message history in memory. The failure only surfaced on chat reload: the DB had zero user rows, so the reconstructed history showed only assistant messages.

The fix drops the workflow field from both inserts and adds console.error on insert failures for both user and assistant rows. No migration needed; the column just wasn't there.

This is worth checking in any fork that copied the insert shape from upstream. Grep for .insert( against chat_messages and compare the column list to your live schema. The defensive logging pattern - capturing { error } from Supabase and logging it rather than ignoring the return value - is worth applying broadly to any DB write that matters.

So what If your fork shares this codebase shape, check the `chat_messages` insert in both chat routes before you trust your message history. The fix itself is two lines. The deeper takeaway is the unchecked Supabase write pattern: PGRST204 doesn't throw, it just silently discards your data.

View this fork on GitHub →

Spotted something wrong? Or know the PR text has fresher detail than the writeup above?

Commits in this thread

1 commit from nwhitehouse/mike, oldest first. Source extracted verbatim from the harvested git log.

SHA Subject Author Date
1271d07c [bug-001] Persist user messages - drop non-existent workflow column Nick Whitehouse 2026-05-03 ↗ GitHub
commit body
User messages were never being persisted to chat_messages. The insert
referenced a `workflow` column that doesn't exist in the schema; Supabase
silently rejected the entire insert with PGRST204 ("Could not find the
'workflow' column of 'chat_messages' in the schema cache"), and the result
was unchecked. Affected both POST /chat and POST /projects/:id/chat.

Effect: chats reloaded from the DB only showed assistant rows. Live chats
appeared correct because the frontend keeps message history in memory.

Fix: drop the `workflow` field from the insert in both routes, and surface
any future insert errors via console.error so the next regression isn't
silent. Same defensive logging added to the assistant-message insert.

If per-message workflow attachment ever needs to survive a reload, add a
column in a follow-up migration.

Verified by direct insert against the prod schema:
  with workflow:    PGRST204 (silently swallowed today)
  without workflow: OK

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

Capture this thread into my fork

Download a single Markdown prompt that tells Claude how to port every commit above into your working tree — adapting paths and structure to match your repo. Run it via claude -p < capture-thread-121.md from inside the repo you want the changes in.

⬇ Download capture-thread-121.md