Repository navigation
Capture exception in edge functions body query - #43628
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Central YAML (base), Repository UI (inherited), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe change wraps the multipart stream parsing loop in a try/catch and integrates Sentry: on exception the code captures the error with Sentry (including error data) and rethrows. The successful parsing and return occur inside the try block. The FileData import was restored to support existing multipart handling. No exported or public API declarations were changed. Sequence Diagram(s)sequenceDiagram
participant Client
participant EdgeFunction
participant MultipartParser
participant Sentry
Client->>EdgeFunction: Send multipart request
EdgeFunction->>MultipartParser: Read multipart stream (loop)
alt parsing succeeds
MultipartParser-->>EdgeFunction: Return metadata + files
EdgeFunction-->>Client: Return result
else parsing error thrown
MultipartParser--x EdgeFunction: Throw error
EdgeFunction->>Sentry: captureException(error, { data })
EdgeFunction--x Client: Rethrow error
end
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/studio/data/edge-functions/edge-function-body-query.ts`:
- Around line 61-67: The catch block incorrectly calls Sentry.captureException
with an object; change it to pass the actual Error object (the variable error)
to Sentry.captureException and avoid sending large/sensitive payloads (do not
include data or response). Preferably replace the Sentry call with the existing
captureCriticalError helper from lib/error-reporting.ts (e.g.
captureCriticalError(error, { boundary })) or call
Sentry.captureException(error) and separately add only minimal safe context
(boundary) via Sentry.setContext or similar; ensure you still rethrow the error
afterwards.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Central YAML (base), Repository UI (inherited), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: 871adc27-1cd6-4a21-83e9-f17970494c7f
📒 Files selected for processing (1)
apps/studio/data/edge-functions/edge-function-body-query.ts
| } catch (error) { | ||
| if (error instanceof Error) | ||
| Sentry.captureException({ | ||
| message: error.message, | ||
| data: { error, data, response, boundary }, | ||
| }) | ||
| throw error |
There was a problem hiding this comment.
Incorrect Sentry.captureException API usage — error won't be captured.
Sentry.captureException expects an Error object as the first argument, not a plain object. The current code passes { message, data } which will not properly capture the exception. This defeats the PR's purpose.
Proposed fix
} catch (error) {
- if (error instanceof Error)
- Sentry.captureException({
- message: error.message,
- data: { error, data, response, boundary },
- })
+ if (error instanceof Error) {
+ Sentry.captureException(error, {
+ extra: { boundary },
+ })
+ }
throw error
}Note: Avoid including data and response in extras as they may contain large/sensitive payloads. If additional context is needed, consider using the existing captureCriticalError helper from lib/error-reporting.ts.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@apps/studio/data/edge-functions/edge-function-body-query.ts` around lines 61
- 67, The catch block incorrectly calls Sentry.captureException with an object;
change it to pass the actual Error object (the variable error) to
Sentry.captureException and avoid sending large/sensitive payloads (do not
include data or response). Preferably replace the Sentry call with the existing
captureCriticalError helper from lib/error-reporting.ts (e.g.
captureCriticalError(error, { boundary })) or call
Sentry.captureException(error) and separately add only minimal safe context
(boundary) via Sentry.setContext or similar; ensure you still rethrow the error
afterwards.
🎭 Playwright Test ResultsDetails
Skipped testsFeatures › sql-editor.spec.ts › SQL Editor › snippet favourite works as expected |
Braintrust eval report
|
Context
Trying to catch any parsing errors into sentry