Skip to content

Fix unhandled errors in edge functions test parsing - #47855

Open
Nyx-abu wants to merge 2 commits into
supabase:masterfrom
Nyx-abu:fix-edge-functions-error-extraction
Open

Nyx-abu wants to merge 2 commits into
supabase:masterfrom
Nyx-abu:fix-edge-functions-error-extraction

Conversation

@Nyx-abu

@Nyx-abu Nyx-abu commented Jul 11, 2026 •

Copy link
Copy Markdown

I have read the CONTRIBUTING.md file.

YES

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

When testing Edge Functions via the Studio API, if the function returns a non-OK status with a JSON response, the API often fails to extract the actual error message. It falls back to a generic "Failed to run edge function" because it assumes a very strict shape of JSON.parse(data).error.

Resolves #47835

What is the new behavior?

The API now checks multiple common error property locations in the JSON response (error.message, error, message, msg) to extract the actual error string. If none are found, it falls back to stringifying the entire JSON object so developers still get the raw context, rather than completely dropping it.

Additional context

Added a docstring to the extractErrorMessage function to improve code coverage and maintainability.

Summary by CodeRabbit

  • Bug Fixes
    • Improved error messages shown when testing edge functions by recognizing several common error response formats.
    • Preserved raw response text when an error response cannot be parsed as JSON.
  • Documentation
    • Added documentation for the edge function test handler.

@Nyx-abu
Nyx-abu requested a review from a team as a code owner July 11, 2026 20:12
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for contributing to Supabase! ❤️ Our team will review your PR.

A few tips for a smoother review process:

  • If you have a local version of the repo, run pnpm run format to make sure formatting checks pass.
  • Once we've reviewed your PR, please don't trivially merge master (don't click Update branch if there are no merge conflicts to be fixed). This invalidates any pre-merge checks we've run.

@vercel

vercel Bot commented Jul 11, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
design-system Ready Ready Preview, Comment Jul 11, 2026 8:33pm
3 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jul 11, 2026 8:33pm
ui-library Skipped Skipped Jul 11, 2026 8:33pm
zone-www-dot-com Skipped Skipped Jul 11, 2026 8:33pm

Request Review

@vercel

vercel Bot commented Jul 11, 2026

Copy link
Copy Markdown

@Nyx-abu is attempting to deploy a commit to the Supabase Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4d8e1580-586f-4543-8501-d619f3da66c5

📥 Commits

Reviewing files that changed from the base of the PR and between 7f7ebff and d5e4d93.

📒 Files selected for processing (1)
  • apps/studio/pages/api/edge-functions/test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/studio/pages/api/edge-functions/test.ts

📝 Walkthrough

Walkthrough

The edge-function test API now extracts error messages from multiple JSON response shapes while preserving the existing status and response structure. JSDoc comments describe the route handler and POST processing flow.

Changes

Edge Function Error Handling

Layer / File(s) Summary
Prioritized error message extraction and handler documentation
apps/studio/pages/api/edge-functions/test.ts
Non-OK JSON responses check error, error.message, message, and msg before using the generic fallback message; JSDoc comments document the exported route handler and handlePost flow.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the Edge Functions test error-parsing fix.
Description check ✅ Passed All required template sections are present and filled with relevant bug-fix details.
Linked Issues check ✅ Passed The changes address #47835 by extracting messages from the listed JSON error shapes in the test API.
Out of Scope Changes check ✅ Passed The added JSDoc comments and fallback handling remain tied to the same error-parsing fix.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Edge Functions Test panel always shows generic error for non-platform, hiding the real failure reason

1 participant