Skip to content

feat(studio-local): functions management api - list functions - #40690

Merged
charislam merged 15 commits into
supabase:masterfrom
kallebysantos:feat-local-functions-management-api-1-list-functions
Jan 30, 2026
Merged

charislam merged 15 commits into
supabase:masterfrom
kallebysantos:feat-local-functions-management-api-1-list-functions

Conversation

@kallebysantos

@kallebysantos kallebysantos commented Nov 21, 2025 •

Copy link
Copy Markdown
Member

consider merge it first - #40584

What kind of change does this PR introduce?

Feature

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

    • Self-hosted edge functions support: filesystem-based artifact listing and a new API to list local functions.
    • Functions UI improvements: unified view, preserved search and new adjacent sort control, and clearer local-hosting guidance.
  • Chores

    • Added env/config and Docker volume for edge-functions management; CI/build config updated to pass through the edge functions env and include contentlayer outputs.

✏️ Tip: You can customize this high-level summary in your review settings.

@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 Nov 21, 2025

Copy link
Copy Markdown

@kallebysantos is attempting to deploy a commit to the Supabase Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Nov 21, 2025 •

Copy link
Copy Markdown

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

Project Deployment Review Updated (UTC)
design-system Ready Ready Preview, Comment Jan 29, 2026 4:20pm
docs Ready Ready Preview, Comment Jan 29, 2026 4:20pm
studio-self-hosted Ready Ready Preview, Comment Jan 29, 2026 4:20pm
studio-staging Ready Ready Preview, Comment Jan 29, 2026 4:20pm
ui-library Ready Ready Preview, Comment Jan 29, 2026 4:20pm
zone-www-dot-com Ready Ready Preview, Comment Jan 29, 2026 4:20pm
2 Skipped Deployments
Project Deployment Review Updated (UTC)
cms Ignored Ignored Jan 29, 2026 4:20pm
studio Ignored Ignored Jan 29, 2026 4:20pm

Request Review

@coveralls

coveralls commented Nov 21, 2025 •

Copy link
Copy Markdown

Coverage Status

coverage: 66.162% (-0.5%) from 66.707%
when pulling 10aac38 on kallebysantos:feat-local-functions-management-api-1-list-functions
into 0c1bc80 on supabase:master.

key={item.id}
onClick={() => {
router.push(`/project/${ref}/functions/${item.slug}`)
IS_PLATFORM && router.push(`/project/${ref}/functions/${item.slug}`)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if !IS_PLATFORM?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its supposed to not open the function page, since this PR is just about the list

@kallebysantos kallebysantos Nov 21, 2025 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to if conditional e2171b8

<TableHead className="lg:table-cell">Deployments</TableHead>
</TableRow>
</TableHeader>
<div className="flex flex-col gap-6">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is never going to resolve in this environment, we shouldn't show it loading

Image

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does resolve when Self-Hosting, the retrieve failed warning should only be displayed when CLI

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UPDATE: supabase/cli#4567 is already prepared to support fn management api

Comment thread apps/studio/.env Resolved
@kallebysantos
kallebysantos force-pushed the feat-local-functions-management-api-1-list-functions branch from 20e7d9c to ae2b409 Compare January 28, 2026 16:33

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/studio/components/interfaces/Functions/EdgeFunctionsListItem.tsx (1)

39-45: Make non-platform rows non-focusable to avoid dead keyboard targets.

When IS_PLATFORM is false, the row is no longer interactive but remains in the tab order (tabIndex={0}), which creates a focusable element that does nothing. Consider disabling focus in that state (and optionally marking it as disabled).

💡 Suggested fix
-      tabIndex={0}
+      tabIndex={IS_PLATFORM ? 0 : -1}
+      aria-disabled={!IS_PLATFORM}
       className={cn({ 'cursor-pointer inset-focus': IS_PLATFORM })}

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@apps/studio/pages/api/v1/projects/`[ref]/functions/index.ts:
- Around line 33-44: The current mapping that builds functions from
functionsArtifacts uses uuidv4() (in the functions variable) which generates a
new random id each request and breaks client-side filters/state; replace the
random id generation with a deterministic ID derived from the function slug
(e.g., compute a stable UUID v5 or a stable hash of func.slug with a fixed
namespace) so the same slug always yields the same id; keep the rest of the
mapped fields and the satisfies EdgeFunctionsResponse typing (update the mapping
that references uuidv4 to call the deterministic generator instead, such as
deterministicIdFromSlug(func.slug)).
🧹 Nitpick comments (1)
apps/studio/pages/api/v1/projects/[ref]/functions/index.ts (1)

24-24: Consider importing the existing type alias.

There's already an EdgeFunctionsResponse type exported from data/edge-functions/edge-functions-query.ts with the same definition. Consider importing it for consistency.

Proposed refactor
-import { components } from 'api-types'
+import { EdgeFunctionsResponse } from 'data/edge-functions/edge-functions-query'
...
-type EdgeFunctionsResponse = components['schemas']['FunctionResponse']

Comment on lines +33 to +44
const functions = functionsArtifacts.map(
(func) =>
({
id: uuidv4(),
slug: func.slug,
version: 1,
name: func.slug,
status: 'ACTIVE',
entrypoint_path: func.entrypoint_path,
created_at: func.created_at,
updated_at: func.updated_at,
}) satisfies EdgeFunctionsResponse

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# Check how the function ID is used in the codebase
rg -n --type=ts --type=tsx 'functions.*\.id|function\.id' apps/studio/ -A 3 -B 3

Repository: supabase/supabase

Length of output: 88


🏁 Script executed:

# Search for usage of the edge functions API endpoint
rg -n --type=ts --type=tsx '/api/v1/projects.*functions' apps/studio/ -A 2 -B 2

Repository: supabase/supabase

Length of output: 88


🏁 Script executed:

# Check if there's any caching of function responses
rg -n --type=ts --type=tsx 'useQuery.*functions|useFetch.*functions' apps/studio/ -A 5 -B 2

Repository: supabase/supabase

Length of output: 88


🏁 Script executed:

# Look for function detail routes/navigation patterns
rg -n --type=ts --type=tsx 'function.*detail|functionId|function-.*id' apps/studio/ -A 3 -B 3

Repository: supabase/supabase

Length of output: 88


🏁 Script executed:

# Check the exact context of the function to understand if this endpoint is meant to be called repeatedly
cat apps/studio/pages/api/v1/projects/\[ref\]/functions/index.ts

Repository: supabase/supabase

Length of output: 1501


🏁 Script executed:

# Search for usage of the edge functions API endpoint without type filter
rg -n 'projects.*functions' apps/studio/ -A 2 -B 2 | head -50

Repository: supabase/supabase

Length of output: 4438


🏁 Script executed:

# Look for edge functions related API calls and imports
rg -n 'getFunctions|EdgeFunctions|functions.*api' apps/studio/pages/ apps/studio/components/ -A 3 -B 1 | head -80

Repository: supabase/supabase

Length of output: 7164


🏁 Script executed:

# Check if there's data caching or state management for functions
rg -n 'useQuery.*functions|functionsQuery|FunctionResponse' apps/studio/ -A 3 -B 1 | head -100

Repository: supabase/supabase

Length of output: 1023


🏁 Script executed:

# Check if function ID is used in URL routes/paths
rg -n 'function.*id|functionId|\[id\]' apps/studio/pages/ -A 2 -B 2 | head -80

Repository: supabase/supabase

Length of output: 6762


Generate stable function IDs instead of random UUIDs to fix filtering and state management.

The endpoint generates a new UUID on every request for the same function, which breaks:

  • Log and invocation filtering (uses selectedFunction.id in metadata.function_id filters)
  • Observability report dropdowns (maps function IDs from the response)
  • Stats queries (passes functionId to stats queries)

Any client-side logic relying on these IDs across multiple endpoint calls will receive different values for the same function.

Proposed fix using deterministic UUID from slug
+import { v5 as uuidv5 } from 'uuid'
+
+// Namespace UUID for edge functions (generate once and keep constant)
+const EDGE_FUNCTIONS_NAMESPACE = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'
+
 const handleGetAll = async (_req: NextApiRequest, res: NextApiResponse) => {
   const store = getFunctionsArtifactStore()

   const functionsArtifacts = await store.getFunctions()
-  if (!functionsArtifacts) return res.status(200).json([])
+  if (functionsArtifacts.length === 0) return res.status(200).json([])

-  // mix some mock data
   const functions = functionsArtifacts.map(
     (func) =>
       ({
-        id: uuidv4(),
+        id: uuidv5(func.slug, EDGE_FUNCTIONS_NAMESPACE),
         slug: func.slug,
         version: 1,
         name: func.slug,
         status: 'ACTIVE',
         entrypoint_path: func.entrypoint_path,
         created_at: func.created_at,
         updated_at: func.updated_at,
       }) satisfies EdgeFunctionsResponse
   )

   return res.status(200).json(functions)
 }
🤖 Prompt for AI Agents
In `@apps/studio/pages/api/v1/projects/`[ref]/functions/index.ts around lines 33 -
44, The current mapping that builds functions from functionsArtifacts uses
uuidv4() (in the functions variable) which generates a new random id each
request and breaks client-side filters/state; replace the random id generation
with a deterministic ID derived from the function slug (e.g., compute a stable
UUID v5 or a stable hash of func.slug with a fixed namespace) so the same slug
always yields the same id; keep the rest of the mapped fields and the satisfies
EdgeFunctionsResponse typing (update the mapping that references uuidv4 to call
the deterministic generator instead, such as
deterministicIdFromSlug(func.slug)).

@charislam charislam left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested local development & hosted

@charislam
charislam enabled auto-merge (squash) January 29, 2026 16:18
@charislam
charislam merged commit 1862b71 into supabase:master Jan 30, 2026
15 checks passed
@github-actions

github-actions Bot commented Jan 30, 2026 •

Copy link
Copy Markdown
Contributor

Braintrust eval report

Assistant (master-1769731327)

Score Average Improvements Regressions
Completeness 80% (-20pp) - 2 🔴
Conciseness 0% (+0pp) - -
Goal Completion 95% (-5pp) - 1 🔴
SQL Identifier Quoting 83.3% (-17pp) - -
SQL Validity 100% (+0pp) - -
Tool Usage 100% (+10pp) 1 🟢 -
Docs Faithfulness 50% (+0pp) - -
Correctness 100% (+0pp) - -
Time_to_first_token 0.21tok (-0.08tok) 9 🟢 1 🔴
Llm_calls 8.2 (+0.1) 3 🟢 2 🔴
Tool_calls 3.6 (+0.7) 3 🟢 2 🔴
Errors 0 (+0) - -
Llm_errors 0 (+0) - -
Tool_errors 0 (+0) - -
Prompt_tokens 81426.6tok (-10254.4tok) 6 🟢 4 🔴
Prompt_cached_tokens 44211.2tok (+9472tok) 7 🟢 1 🔴
Prompt_cache_creation_tokens 0tok (+0tok) - -
Completion_tokens 5780.2tok (-634.6tok) 5 🟢 5 🔴
Completion_reasoning_tokens 4288tok (-192tok) 5 🟢 4 🔴
Completion_accepted_prediction_tokens 0tok (+0tok) - -
Completion_rejected_prediction_tokens 0tok (+0tok) - -
Completion_audio_tokens 0tok (+0tok) - -
Total_tokens 87206.8tok (-10889tok) 7 🟢 3 🔴
Estimated_cost 0.02$ (-0.01$) 6 🟢 4 🔴
Duration 43.55s (-10.83s) 6 🟢 4 🔴
Llm_duration 86.34s (-21.28s) 6 🟢 4 🔴

charislam added a commit that referenced this pull request Feb 18, 2026
…nments (#42992)

Feature

## What is the current behavior?

The Functions counter on the Home page is only displayed in platform
environments.
In self-hosted setups, the counter is hidden due to a platform guard,
even though Functions may be available.

## What is the new behavior?

The Functions counter is now also displayed in self-hosted environments.

This is now possible thanks to the following PRs:

- #40690  
- #42322  
- #42349  
- #42350  

These PRs introduce and enable the API required for listing Functions in
Studio, making it feasible to show the Functions count outside of the
platform environment.

## Additional context

Related issues: #36285

This change removes the platform-only restriction around the Functions
card in the Home interface, allowing feature parity between platform and
self-hosted deployments where the Functions API is available.

---------

Co-authored-by: Andrey A. <[email protected]>
Co-authored-by: Charis Lam <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli Related to supabase/cli self-hosted Related to self-hosted Supabase

Projects

Development

Successfully merging this pull request may close these issues.

8 participants