Skip to content

Commit ec2dca3

Browse files
waleedlatif1claude
andcommitted
fix: address PR review comments on staging release
- Add try/catch around clipboard.writeText() in CopyCodeButton - Add missing folder and past_chat cases in resolveResourceFromContext - Return 400 for ZodError instead of 500 in all 8 Athena API routes Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9282d1b commit ec2dca3

File tree

10 files changed

+60
-4
lines changed

10 files changed

+60
-4
lines changed

apps/sim/app/api/tools/athena/create-named-query/route.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ export async function POST(request: NextRequest) {
5555
},
5656
})
5757
} catch (error) {
58+
if (error instanceof z.ZodError) {
59+
return NextResponse.json(
60+
{ error: error.errors[0]?.message ?? 'Invalid request' },
61+
{ status: 400 }
62+
)
63+
}
5864
const errorMessage =
5965
error instanceof Error ? error.message : 'Failed to create Athena named query'
6066
logger.error('CreateNamedQuery failed', { error: errorMessage })

apps/sim/app/api/tools/athena/get-named-query/route.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ export async function POST(request: NextRequest) {
5353
},
5454
})
5555
} catch (error) {
56+
if (error instanceof z.ZodError) {
57+
return NextResponse.json(
58+
{ error: error.errors[0]?.message ?? 'Invalid request' },
59+
{ status: 400 }
60+
)
61+
}
5662
const errorMessage = error instanceof Error ? error.message : 'Failed to get Athena named query'
5763
logger.error('GetNamedQuery failed', { error: errorMessage })
5864
return NextResponse.json({ error: errorMessage }, { status: 500 })

apps/sim/app/api/tools/athena/get-query-execution/route.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ export async function POST(request: NextRequest) {
6363
},
6464
})
6565
} catch (error) {
66+
if (error instanceof z.ZodError) {
67+
return NextResponse.json(
68+
{ error: error.errors[0]?.message ?? 'Invalid request' },
69+
{ status: 400 }
70+
)
71+
}
6672
const errorMessage =
6773
error instanceof Error ? error.message : 'Failed to get Athena query execution'
6874
logger.error('GetQueryExecution failed', { error: errorMessage })

apps/sim/app/api/tools/athena/get-query-results/route.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ export async function POST(request: NextRequest) {
7474
},
7575
})
7676
} catch (error) {
77+
if (error instanceof z.ZodError) {
78+
return NextResponse.json(
79+
{ error: error.errors[0]?.message ?? 'Invalid request' },
80+
{ status: 400 }
81+
)
82+
}
7783
const errorMessage =
7884
error instanceof Error ? error.message : 'Failed to get Athena query results'
7985
logger.error('GetQueryResults failed', { error: errorMessage })

apps/sim/app/api/tools/athena/list-named-queries/route.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ export async function POST(request: NextRequest) {
5151
},
5252
})
5353
} catch (error) {
54+
if (error instanceof z.ZodError) {
55+
return NextResponse.json(
56+
{ error: error.errors[0]?.message ?? 'Invalid request' },
57+
{ status: 400 }
58+
)
59+
}
5460
const errorMessage =
5561
error instanceof Error ? error.message : 'Failed to list Athena named queries'
5662
logger.error('ListNamedQueries failed', { error: errorMessage })

apps/sim/app/api/tools/athena/list-query-executions/route.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ export async function POST(request: NextRequest) {
5151
},
5252
})
5353
} catch (error) {
54+
if (error instanceof z.ZodError) {
55+
return NextResponse.json(
56+
{ error: error.errors[0]?.message ?? 'Invalid request' },
57+
{ status: 400 }
58+
)
59+
}
5460
const errorMessage =
5561
error instanceof Error ? error.message : 'Failed to list Athena query executions'
5662
logger.error('ListQueryExecutions failed', { error: errorMessage })

apps/sim/app/api/tools/athena/start-query/route.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ export async function POST(request: NextRequest) {
6767
},
6868
})
6969
} catch (error) {
70+
if (error instanceof z.ZodError) {
71+
return NextResponse.json(
72+
{ error: error.errors[0]?.message ?? 'Invalid request' },
73+
{ status: 400 }
74+
)
75+
}
7076
const errorMessage = error instanceof Error ? error.message : 'Failed to start Athena query'
7177
logger.error('StartQuery failed', { error: errorMessage })
7278
return NextResponse.json({ error: errorMessage }, { status: 500 })

apps/sim/app/api/tools/athena/stop-query/route.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ export async function POST(request: NextRequest) {
4343
},
4444
})
4545
} catch (error) {
46+
if (error instanceof z.ZodError) {
47+
return NextResponse.json(
48+
{ error: error.errors[0]?.message ?? 'Invalid request' },
49+
{ status: 400 }
50+
)
51+
}
4652
const errorMessage = error instanceof Error ? error.message : 'Failed to stop Athena query'
4753
logger.error('StopQuery failed', { error: errorMessage })
4854
return NextResponse.json({ error: errorMessage }, { status: 500 })

apps/sim/app/workspace/[workspaceId]/home/home.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,10 @@ export function Home({ chatId }: HomeProps = {}) {
273273
return context.tableId ? { type: 'table', id: context.tableId } : null
274274
case 'file':
275275
return context.fileId ? { type: 'file', id: context.fileId } : null
276+
case 'folder':
277+
return context.folderId ? { type: 'folder', id: context.folderId } : null
278+
case 'past_chat':
279+
return context.chatId ? { type: 'task', id: context.chatId } : null
276280
default:
277281
return null
278282
}

apps/sim/components/ui/copy-code-button.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@ export function CopyCodeButton({ code, className }: CopyCodeButtonProps) {
1414
const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null)
1515

1616
const handleCopy = useCallback(async () => {
17-
await navigator.clipboard.writeText(code)
18-
setCopied(true)
19-
if (timerRef.current) clearTimeout(timerRef.current)
20-
timerRef.current = setTimeout(() => setCopied(false), 2000)
17+
try {
18+
await navigator.clipboard.writeText(code)
19+
setCopied(true)
20+
if (timerRef.current) clearTimeout(timerRef.current)
21+
timerRef.current = setTimeout(() => setCopied(false), 2000)
22+
} catch {
23+
// Clipboard write can fail when document lacks focus or permission is denied
24+
}
2125
}, [code])
2226

2327
useEffect(

0 commit comments

Comments
 (0)