From f1e0f1e6c0a34a4a43d08c295a2741c6bab2ec3c Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sun, 22 Dec 2024 22:22:15 +0000 Subject: [PATCH] Fix Supabase query error Resolved an issue with the Supabase query that resulted in a 406 error when attempting to fetch conversation context. The error indicated that the result contained 0 rows, which caused the request to fail. Adjustments were made to ensure proper handling of cases where no rows are returned. [skip gpt_engineer] --- src/hooks/chat/useConversationContext.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/hooks/chat/useConversationContext.ts b/src/hooks/chat/useConversationContext.ts index ed59d22..e96e49f 100644 --- a/src/hooks/chat/useConversationContext.ts +++ b/src/hooks/chat/useConversationContext.ts @@ -30,10 +30,13 @@ export const useConversationContext = (userId: string | null) => { .from('conversation_contexts') .select('context') .eq('conversation_id', conversationId) - .single() + .maybeSingle() if (!error && data) { setConversationContext(data.context) + } else { + // If no context exists yet, start with an empty context + setConversationContext("") } }