-
Notifications
You must be signed in to change notification settings - Fork 106
base natural postgres attached to database. #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: starter
Are you sure you want to change the base?
Changes from 1 commit
0ec8d4f
898ad93
1ef5771
9d9a036
c0df009
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| import { useState } from "react"; | ||
| import { Button } from "./ui/button"; | ||
| import { QueryWithTooltips } from "./ui/query-with-tooltips"; | ||
| import { explainQuery } from '@/app/actions'; | ||
| import { QueryExplanation } from "@/lib/types"; | ||
| import { CircleHelp, Loader2 } from "lucide-react"; | ||
|
|
||
|
|
@@ -21,8 +22,8 @@ export const QueryViewer = ({ | |
| setQueryExpanded(true); | ||
| setLoadingExplanation(true); | ||
|
|
||
| // TODO: generate explanation and update state | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The View Details📝 Patch Detailsdiff --git a/components/query-viewer.tsx b/components/query-viewer.tsx
index 216d2ca..7646f9b 100644
--- a/components/query-viewer.tsx
+++ b/components/query-viewer.tsx
@@ -4,6 +4,7 @@ import { QueryWithTooltips } from "./ui/query-with-tooltips";
import { explainQuery } from '@/app/actions';
import { QueryExplanation } from "@/lib/types";
import { CircleHelp, Loader2 } from "lucide-react";
+import { toast } from "sonner";
export const QueryViewer = ({
activeQuery,
@@ -22,9 +23,15 @@ export const QueryViewer = ({
setQueryExpanded(true);
setLoadingExplanation(true);
-const explanations = await explainQuery(inputValue, activeQuery);
- setQueryExplanations(explanations);
- setLoadingExplanation(false);
+ try {
+ const explanations = await explainQuery(inputValue, activeQuery);
+ setQueryExplanations(explanations);
+ } catch (error) {
+ console.error('Failed to generate explanation:', error);
+ toast.error('Failed to generate explanation. Please try again.');
+ } finally {
+ setLoadingExplanation(false);
+ }
};
if (activeQuery.length === 0) return null;
AnalysisMissing error handling in handleExplainQuery leaves UI in loading stateWhat fails: How to reproduce:
Result: Unhandled promise rejection; loading state remains Expected: Errors should be caught, loading state should always be cleared, and user should receive error feedback via toast notification. Fix implemented: Added try-catch-finally block to
This follows the same error handling pattern used elsewhere in the codebase (see |
||
|
|
||
| const explanations = await explainQuery(inputValue, activeQuery); | ||
| setQueryExplanations(explanations); | ||
| setLoadingExplanation(false); | ||
| }; | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The table name in the error message check was changed from "unicorns" to "relation", which will prevent the error handler from catching the expected error condition. This is likely a copy-paste error from a template.
View Details
Analysis
Incorrect table name in error handler prevents missing table detection
What fails: The
runGeneratedSQLQuery()function fails to catch missing table errors because it checks for'relation "relation" does not exist'instead of the actual table name'relation "unicorns" does not exist'How to reproduce:
Result: PostgreSQL returns error message:
'relation "unicorns" does not exist'(includes actual table name per PostgreSQL error format)The condition
e.message.includes('relation "relation" does not exist')never matches, so the error falls through toelse { throw e; }and propagates to the user instead of being handled gracefully.Expected: According to PostgreSQL documentation and error message format specifications, when a table doesn't exist, the error message includes the actual table name:
'relation "unicorns" does not exist'. The check should match this specific error to catch it and handle the missing table condition.Fix: Changed line 78 from checking for
'relation "relation" does not exist'to the correct'relation "unicorns" does not exist'