Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Capture exception in edge functions body query (#43628)

Joshen Limc0692111b706
diff --git a/.mcp.json b/.mcp.json
new file mode 100644
index 00000000000..42694d08700
--- /dev/null
+++ b/.mcp.json
@@ -0,0 +1,8 @@
+{
+ "mcpServers": {
+ "supabase": {
+ "type": "http",
+ "url": "https://mcp.supabase.com/mcp"
+ }
+ }
+}
\ No newline at end of file
diff --git a/apps/studio/data/edge-functions/edge-function-body-query.ts b/apps/studio/data/edge-functions/edge-function-body-query.ts
index 8ee38e9a930..b9ac31bc1a4 100644
--- a/apps/studio/data/edge-functions/edge-function-body-query.ts
+++ b/apps/studio/data/edge-functions/edge-function-body-query.ts
@@ -1,11 +1,11 @@
import { getMultipartBoundary, parseMultipartStream } from '@mjackson/multipart-parser'
+import * as Sentry from '@sentry/nextjs'
import { useQuery } from '@tanstack/react-query'
-
-import { FileData } from '@/components/ui/FileExplorerAndEditor/FileExplorerAndEditor.types'
import { get, handleError } from 'data/fetchers'
-import { IS_PLATFORM } from 'lib/constants'
import type { ResponseError, UseCustomQueryOptions } from 'types'
+
import { edgeFunctionsKeys } from './keys'
+import { FileData } from '@/components/ui/FileExplorerAndEditor/FileExplorerAndEditor.types'
type EdgeFunctionBodyVariables = {
projectRef?: string
@@ -38,24 +38,33 @@ export async function getEdgeFunctionBody(
deno2_entrypoint_path?: string | null
} = {}
- for await (let part of parseMultipartStream(data, {
- boundary,
- maxFileSize: 20 * 1024 * 1024,
- })) {
- if (part.isFile) {
- files.push({
- name: part.filename,
- content: part.text,
- })
- } else {
- // treat it as metadata
- metadata = JSON.parse(part.text)
+ try {
+ for await (let part of parseMultipartStream(data, {
+ boundary,
+ maxFileSize: 20 * 1024 * 1024,
+ })) {
+ if (part.isFile) {
+ files.push({
+ name: part.filename,
+ content: part.text,
+ })
+ } else {
+ // treat it as metadata
+ metadata = JSON.parse(part.text)
+ }
}
- }
- return {
- metadata,
- files: files as Omit<FileData, 'id' | 'selected' | 'state'>[],
+ return {
+ metadata,
+ files: files as Omit<FileData, 'id' | 'selected' | 'state'>[],
+ }
+ } catch (error) {
+ if (error instanceof Error) {
+ Sentry.captureException(error, {
+ extra: { error, data, response, boundary },
+ })
+ }
+ throw error
}
}