From 237a1124f39c7d70b12376d34e0ed879a049a6ba Mon Sep 17 00:00:00 2001 From: Contentrain Date: Fri, 15 May 2026 13:12:39 +0300 Subject: [PATCH] fix(chat): remove non-existent status/workspace_id from conversations SELECT MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The DatabaseProvider abstraction refactor (ba75732) added `status` and `workspace_id` to the `getConversation` SELECT list, but these columns were never created on `public.conversations` — the table only has `id, project_id, user_id, title, created_at, updated_at`. As a result, every chat request hit `column conversations.status does not exist` and returned a 500. No caller reads `conv.status` or `conv.workspace_id` (verified across chat.post, messages.get, conversation delete, EE conversation-api, and the ConversationSummary type consumed by ChatPanel / CommandPalette). Billing/quota scoping already lives on `agent_usage.workspace_id`; the RLS policy on `conversations` is `user_id = auth.uid()` and does not need workspace denormalisation. Adding a migration for unused columns would be speculative design, so this drops the over-selected fields and the matching `workspaceId?` filter on the provider interface (no caller passes it). --- server/providers/database.ts | 2 +- server/providers/supabase-db/conversations.ts | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/server/providers/database.ts b/server/providers/database.ts index c57968b..0a5d137 100644 --- a/server/providers/database.ts +++ b/server/providers/database.ts @@ -251,7 +251,7 @@ export interface DatabaseProvider { // ═══════════════════════════════════════════════════ createConversation: (projectId: string, userId: string, title: string) => Promise - getConversation: (conversationId: string, projectId: string, filters?: { userId?: string, workspaceId?: string }) => Promise + getConversation: (conversationId: string, projectId: string, filters?: { userId?: string }) => Promise listConversations: (accessToken: string, projectId: string, userId: string) => Promise deleteConversation: (accessToken: string, conversationId: string, userId: string, projectId: string) => Promise updateConversationTimestamp: (conversationId: string) => Promise diff --git a/server/providers/supabase-db/conversations.ts b/server/providers/supabase-db/conversations.ts index 83b7fd1..69d030d 100644 --- a/server/providers/supabase-db/conversations.ts +++ b/server/providers/supabase-db/conversations.ts @@ -43,12 +43,11 @@ export function conversationMethods(): ConversationMethods { const admin = getAdmin() let query = admin .from('conversations') - .select('id, title, status, user_id, workspace_id, created_at, updated_at') + .select('id, title, user_id, created_at, updated_at') .eq('id', conversationId) .eq('project_id', projectId) if (filters?.userId) query = query.eq('user_id', filters.userId) - if (filters?.workspaceId) query = query.eq('workspace_id', filters.workspaceId) const { data, error } = await query.single() if (error) {