mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 01:45:10 +03:00
fix: Add a catch block around a JSON.parse when rendering AI assistant messages (#34671)
Add a catch block around a json.parse.
This commit is contained in:
1 parent
e36f1715b3
commit
86a690b00a
1 file changed
+8
-4
@@ -185,10 +185,14 @@ export const MarkdownPre = ({
|
||||
const rawContent = children[0].props.children[0]
|
||||
const propsMatch = rawContent.match(/(?:--|\/\/)\s*props:\s*(\{[^}]+\})/)
|
||||
|
||||
const snippetProps: AssistantSnippetProps = useMemo(
|
||||
() => (propsMatch ? JSON.parse(propsMatch[1]) : {}),
|
||||
[propsMatch]
|
||||
)
|
||||
const snippetProps: AssistantSnippetProps = useMemo(() => {
|
||||
try {
|
||||
if (propsMatch) {
|
||||
return JSON.parse(propsMatch[1])
|
||||
}
|
||||
} catch {}
|
||||
return {}
|
||||
}, [propsMatch])
|
||||
|
||||
const { xAxis, yAxis } = snippetProps
|
||||
const snippetId = snippetProps.id
|
||||
|
||||
Reference in new issue
Block a user