Repository navigation
Conversation
|
Thanks for contributing to Supabase! ❤️ Our team will review your PR. A few tips for a smoother review process:
|
|
@kallebysantos is attempting to deploy a commit to the Supabase Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| key={item.id} | ||
| onClick={() => { | ||
| router.push(`/project/${ref}/functions/${item.slug}`) | ||
| IS_PLATFORM && router.push(`/project/${ref}/functions/${item.slug}`) |
There was a problem hiding this comment.
Its supposed to not open the function page, since this PR is just about the list
| <TableHead className="lg:table-cell">Deployments</TableHead> | ||
| </TableRow> | ||
| </TableHeader> | ||
| <div className="flex flex-col gap-6"> |
There was a problem hiding this comment.
It does resolve when Self-Hosting, the retrieve failed warning should only be displayed when CLI
There was a problem hiding this comment.
UPDATE: supabase/cli#4567 is already prepared to support fn management api
20e7d9c to
ae2b409
Compare
There was a problem hiding this comment.
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_PLATFORMis 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 })}
There was a problem hiding this comment.
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
EdgeFunctionsResponsetype exported fromdata/edge-functions/edge-functions-query.tswith 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']
| 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 |
There was a problem hiding this comment.
🧩 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 3Repository: 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 2Repository: 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 2Repository: 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 3Repository: 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.tsRepository: 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 -50Repository: 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 -80Repository: 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 -100Repository: 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 -80Repository: 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.idinmetadata.function_idfilters) - Observability report dropdowns (maps function IDs from the response)
- Stats queries (passes
functionIdto 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
left a comment
There was a problem hiding this comment.
Tested local development & hosted
Braintrust eval report
|
…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]>

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
Chores
✏️ Tip: You can customize this high-level summary in your review settings.