## Problem
In self-hosted and local Studio, `FileSystemFunctionsArtifactStore`
reads the folder set by `EDGE_FUNCTIONS_MANAGEMENT_FOLDER` with
`readdir`. When that folder does not exist yet (for example, a fresh
project before any function is created), `readdir` throws `ENOENT`, the
`/api/v1/projects/[ref]/functions` route returns a 500, and the Edge
Functions page shows "Failed to retrieve edge functions" instead of its
empty state.
## Solution
- Add a private `readFunctionsFolder()` helper that returns an empty
list when the folder is missing (`ENOENT`) and rethrows every other
error.
- `getFunctions()` now returns `[]` and `getFunctionBySlug()` returns
`undefined` for a missing folder.
- Add `fileSystemStore.test.ts`, which uses real temp folders to cover
the missing folder, a non-ENOENT error (path is a file), and the normal
listing (skips `main` and folders without an `index` entrypoint).
No change to the hosted platform path.
## Review instructions
This only affects self-hosted Studio, so the Vercel preview cannot show
it. Check it with:
1. `cd apps/studio && pnpm exec vitest run
lib/api/self-hosted/functions/`: all tests pass.
2. Optional, locally: run self-hosted Studio with
`EDGE_FUNCTIONS_MANAGEMENT_FOLDER` pointing to a folder that does not
exist, open Edge Functions, and see the empty state instead of a 500.
Checks run: the Vitest command above, `pnpm turbo run typecheck
--filter='...[origin/master]'`, ESLint and Prettier on the changed
files.
## 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, which applies the docs
[style
guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)
[FE-4923](https://linear.app/supabase/issue/FE-4923/fix-studio-edge-functions-500-error-when-local-functions-folder-does)
---------
Co-authored-by: supabase-vercel-tedd[bot] <336548405+supabase-vercel-tedd[bot]@users.noreply.github.com>
Co-authored-by: Ali Waseem <waseema393@gmail.com>
## What kind of change does this PR introduce?
Feature
## What is the current behavior?
Functions page on self-hosted differs from Platform
## What is the new behavior?
> [!NOTE]
> This PR only add readonly operations. Function edit and deploy should
be implemented in a future one.
Adds the possibility to download and see function code in Self-Host
version.
<details>
<img width="1465" height="944" alt="image"
src="https://github.com/user-attachments/assets/4bbf8f5c-3390-4de6-9e8b-8ec9cd59ebad"
/>
</details>
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* API endpoint to stream function files/artifacts as
multipart/form-data.
* New function file entry type and server-side file listing for
functions.
* **Improvements**
* Edge Functions "Code" navigation item always visible.
* Download popover reworked: ZIP download always available; CLI section
shown only on supported platforms.
* Editor set to read-only and file actions disabled on unsupported
environments.
* **Editor**
* Added JavaScript, TypeScript, and Markdown language modules for the
embedded editor.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Charis Lam <26616127+charislam@users.noreply.github.com>
Functions page on self-hosted differs from Platform Adds the possibility to see function details page in Self-Host version.
## Summary by CodeRabbit
* **New Features**
* Edge function detail lookup added for self‑hosted deployments (new
retrieval endpoint & store method).
* Consistent navigation to function pages from the functions list.
* **Improvements**
* UI tabs, download, and test controls adapt to deployment type.
* Region, JWT verification, local development, and delete controls shown
only on the platform.
* Edit/save/delete controls enable/disable correctly based on deployment
and permissions.
* Function details load reliably across deployments.
## What is the current behaviour?
Functions page on self-hosted differs from Platform
## What is the new behaviour?
Adds the possibility to see a list of edge-functions in Self-Host
version.
## Summary by CodeRabbit
* **New Features**
* Added self-hosted edge functions support with filesystem-based
artifact listing and a new API endpoint to list local functions.
* Improved functions UI: unified view, enhanced search and adjacent sort
controls, and clearer local-hosting guidance.
* **Chores**
* Added environment configuration and docker volume for edge functions
management.
* Updated build/task config to pass through edge functions env and
include contentlayer outputs.
Co-authored-by: Ali Waseem <waseema393@gmail.com>
Co-authored-by: Charis Lam <26616127+charislam@users.noreply.github.com>
Co-authored-by: Terry Sutton <saltcod@gmail.com>