Skip to content

Conversation

@johnstonmatt
Copy link

@johnstonmatt johnstonmatt commented Oct 29, 2025

What kind of change does this PR introduce?

Feature DEVWF-756

What is the current behavior?

  • supabase functions download foo spins up an edge-runtime container to download the eszip bundle and writes it to the filesystem

What is the new behavior?

  • supabase functions download foo --use-api calls the mgmt-api to unbundle the eszip on the server, then returns it as a multipart response and writes it to the filesystem

Parity

We expect that whether you choose to --use-api or not you should end up with the same files on disk.

Additional context

Add any other context or screenshots.

@johnstonmatt johnstonmatt requested a review from a team as a code owner October 29, 2025 08:46
@coveralls
Copy link

coveralls commented Oct 29, 2025

Pull Request Test Coverage Report for Build 19088750195

Details

  • 43 of 126 (34.13%) changed or added relevant lines in 2 files are covered.
  • 5 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.2%) to 54.482%

Changes Missing Coverage Covered Lines Changed/Added Lines %
cmd/functions.go 0 13 0.0%
internal/functions/download/download.go 43 113 38.05%
Files with Coverage Reduction New Missed Lines %
internal/gen/keys/keys.go 5 12.9%
Totals Coverage Status
Change from base Build 19065008112: -0.2%
Covered Lines: 6430
Relevant Lines: 11802

💛 - Coveralls

@johnstonmatt johnstonmatt disabled auto-merge October 31, 2025 09:20
@johnstonmatt johnstonmatt force-pushed the DEVWF-756/server-side-unbundle branch 2 times, most recently from 3444cce to fb7041d Compare November 3, 2025 18:04
@johnstonmatt johnstonmatt force-pushed the DEVWF-756/server-side-unbundle branch from fb7041d to 3eedb2c Compare November 3, 2025 18:07
// remove leading source/ or :slug/
func normalizeRelativePath(slug, raw string) string {
cleaned := path.Clean(raw)
if after, ok := strings.CutPrefix(cleaned, "source/"); ok {
Copy link
Contributor

Choose a reason for hiding this comment

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

What if user legitimately uses a directory named source? I think it's too magical to deal with it here.

A more general solve for this is to return another path header that can be used to indicate the root directory to extract. For eg.

We may have source/index.ts as the file path. By specifying source as the path header, the file will be downloaded to supabase/functions/slug/index.ts. Otherwise it will be extracted to supabase/functions/slug/source/index.ts.

Copy link
Contributor

Choose a reason for hiding this comment

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

Alternatively, we can also make use of the entrypoint path field of the metadata to locate the desired slug directory within the eszip bundle.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I think a better approach would be to look at the entrypoint (this may need an extra request to get metadata) and figure out the common base path. You can look at how it's implemented in the dashboard https://github.com/supabase/supabase/blob/master/apps/studio/pages/project/%5Bref%5D/functions/%5BfunctionSlug%5D/code.tsx#L178-L197

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.

5 participants