Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion apps/sim/app/(landing)/partners/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Metadata } from 'next'
import Link from 'next/link'
import { getNavBlogPosts } from '@/lib/blog/registry'
import { martianMono } from '@/app/_styles/fonts/martian-mono/martian-mono'
import { season } from '@/app/_styles/fonts/season/season'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -711,11 +711,24 @@ export const StructuredOutput = memo(function StructuredOutput({
}, [])

// Reset expanded paths when data changes
const prevDataJsonRef = useRef<string>('')

useEffect(() => {
if (prevDataRef.current !== data || prevIsErrorRef.current !== isError) {
if (prevIsErrorRef.current !== isError) {
prevDataRef.current = data
prevIsErrorRef.current = isError
prevDataJsonRef.current = JSON.stringify(data)
setExpandedPaths(computeInitialPaths(data, isError))
return
}

if (prevDataRef.current !== data) {
const newJson = JSON.stringify(data)
if (prevDataJsonRef.current !== newJson) {
prevDataJsonRef.current = newJson
setExpandedPaths(computeInitialPaths(data, isError))
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unguarded JSON.stringify can throw on non-serializable data

Medium Severity

The new deep-equality check calls JSON.stringify(data) without a try-catch. If data contains circular references, BigInt values, or other non-JSON-serializable structures, this will throw an unhandled error and crash the structured output component. The previous code only compared by reference (prevDataRef.current !== data), which can never throw.

Additional Locations (1)
Fix in Cursor Fix in Web

prevDataRef.current = data
}
}, [data, isError])

Expand Down
Loading