mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
<!-- claude-slack-attribution --> _Requested by **Kalleby Santos** · [Slack thread](https://supabase.slack.com/archives/C02KMRX22NR/p1794750855761849?thread_ts=1794750855.761849&cid=C02KMRX22NR)_ ## Problem **Before:** When an Edge Function's source is too large to load in Studio, the function's Code tab shows "Failed to load function code" with the same steps as any other load failure: update the CLI, then redeploy with `supabase functions deploy` or use the Management API. Redeploying does not help here, because the problem is the size of the code, not a bad deployment. **After:** When the function body request fails because the code exceeds the maximum size (HTTP 507), the same error screen tells the reader to update the CLI and then download the function with `supabase functions download <function-slug>`. All other load errors keep the existing redeploy and Management API steps. ## Solution Adds `isFunctionBodyMaxSizeError` (true when the error code is 507) next to the function body query, and the Code page uses it to pick which step 2 to show. Studio already preserves the HTTP status as `error.code`, so no changes to error classification are needed. This ports Kalleby's fork commit [498a1b1](https://github.com/kallebysantos/supabase/commit/498a1b1b386accea4fa57a85a3a2328b79a3b34c) onto current master. Differences from the original: it types the helper against Studio's current error shape instead of `ResponseError`, fixes the "Donwload" typo, and adds a small unit test for the helper. Co-authored-by: Kalleby Santos <kalleby_santos@hotmail.com> ## Review instructions 1. Open a function's Code tab where the function body request returns 507 (for example by mocking the response) and confirm step 2 reads "Download your function using: `supabase functions download <slug>`" with no Management API step. 2. Trigger any other body load error and confirm the redeploy and Management API steps are unchanged. ## Checklist - [x] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) - [ ] If I wrote a new docs topic or edited an existing topic, I used the `/write-the-docs` or `/edit-the-docs` skill (not applicable, no docs changes) --- _Generated by [Claude Code](https://claude.ai/code/session_01JZqbAVr5Epmzu7mKWMj9jD)_ --------- Co-authored-by: Kalleby Santos <kalleby_santos@hotmail.com> Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com> Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
20 lines
628 B
TypeScript
20 lines
628 B
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import { isFunctionBodyMaxSizeError } from './edge-function-body-query'
|
|
|
|
describe('isFunctionBodyMaxSizeError', () => {
|
|
it('is true for a 507 error', () => {
|
|
expect(isFunctionBodyMaxSizeError({ code: 507 })).toBe(true)
|
|
})
|
|
|
|
it('is false for other status codes', () => {
|
|
expect(isFunctionBodyMaxSizeError({ code: 500 })).toBe(false)
|
|
expect(isFunctionBodyMaxSizeError({})).toBe(false)
|
|
})
|
|
|
|
it('is false when there is no error', () => {
|
|
expect(isFunctionBodyMaxSizeError(null)).toBe(false)
|
|
expect(isFunctionBodyMaxSizeError(undefined)).toBe(false)
|
|
})
|
|
})
|