Skip to content

fix(mcp-server-supabase): stop reusing a removed import map on edge function redeploy - #588

Merged
barryroodt merged 1 commit into
supabase:mainfrom
Heman10x-NGU:fix/deploy-edge-function-stale-import-map
Nov 24, 2026
Merged

barryroodt merged 1 commit into
supabase:mainfrom
Heman10x-NGU:fix/deploy-edge-function-stale-import-map

Conversation

@Heman10x-NGU

@Heman10x-NGU Heman10x-NGU commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

Fixes #587. The fix follows the expected behavior described in that issue.

An import map is the file that tells an Edge Function where its imports come from: deno.json, deno.jsonc, or import_map.json.

When deploy_edge_function redeploys a function and the caller does not pass import_map_path, the tool reuses the path from the last deploy. It does this even when that file is no longer in the upload.

Example: a function was deployed with import_map.json. It is redeployed with index.ts and deno.jsonc. The request still names import_map.json as the import map. That file was not sent, and the tool ignores the new deno.jsonc. The Management API then rejects the deploy with import map path does not exist.

This is the move the docs recommend: Managing dependencies calls import_map.json legacy and says to use deno.json. A redeploy that makes this move is the case that breaks.

What is the new behavior?

When import_map_path is not passed, the tool reuses the old path only if that file is in the new upload. If it is not, the tool picks the import map from the new files, the same way it does on a first deploy.

Redeploy without import_map_path Before After
Upload still has the old import map old path old path
Upload has deno.jsonc instead old path deno.jsonc
Upload has no import map old path no import map

A file sent as ./import_map.json counts as import_map.json, so redeploys that use ./ names work as before. If the caller passes import_map_path, the tool still uses it. No tool metadata changes.

How to Review

  1. Import map choice

    • packages/mcp-server-supabase/src/platform/api-platform.ts
    • In deployEdgeFunction, the fallback now checks the uploaded file names before it reuses the old path.
  2. Tests

    • packages/mcp-server-supabase/src/server.functions.test.ts
    • Three new cases sit after "updating edge function with missing import_map_path defaults to previous value". One swaps import_map.json for deno.jsonc. One uploads no import map. One uploads ./import_map.json.

Review questions

  • When the new upload has no import map, the function now deploys without one. Is that right, or should the tool return an error?
  • Upload names go through normalize from node:path/posix before the comparison. Is that the right way to match them to the stored path?
  • The stored path comes from getEdgeFunction, which strips the deploy folder and source/. Is there a stored path this comparison would miss?
  • On main, getDefaultImportMapPath does not match ./deno.json on a first deploy. I left that out to keep this PR to one bug. Should it be its own issue?

Verification

Node 24.22.3, pnpm 10.33.2, after pnpm build:

  • Unit suite for @supabase/mcp-server-supabase (vitest --project unit --run): 35 files, 934 tests passed.
  • With the api-platform.ts change reverted, the three new tests give 2 failed and 1 passed. The ./ test passes on main because main always reuses the old path. It is there because my first version of this fix compared names exactly and broke that case.
  • tsc --noEmit in packages/mcp-server-supabase and pnpm format:check: clean.

I also checked how the real Management API answers, on a hosted test project. I sent both requests by hand through the hosted MCP server, with index.ts, greeting_v2.ts, and deno.jsonc uploaded and import_map_path set explicitly:

  • import_map_path: "import_map.json", the request main builds in this case: rejected with BadRequestException: import map path does not exist.
  • import_map_path: "deno.jsonc", the request this branch builds: deployed as version 2.

I did not run this branch itself against a hosted project. Its own tests use the repo's mocked Management API.

Additional context

The CLI does not have this problem. It takes the import map path from local config and uploads that file in the same request (apps/cli/src/shared/functions/deploy.ts in supabase/cli).

@barryroodt barryroodt 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.

Thanks for checking both requests against a hosted project! Comparing normalized paths makes sense here since ./deno.json and deno.json refer to the same file. If the new upload has no map, I'd let the redeploy go ahead without one. That matches a first deploy and gives callers a way to remove an old map. #591 covers ./ on first deploys too.

@barryroodt
barryroodt merged commit 56093a6 into supabase:main Nov 24, 2026
5 of 7 checks passed
@supabase-releaser supabase-releaser Bot mentioned this pull request Nov 24, 2026
barryroodt pushed a commit that referenced this pull request Nov 26, 2026
🤖 I have created a release *beep* *boop*
---


<details><summary>mcp-utils: 0.11.1</summary>

##
[0.11.1](mcp-utils-v0.11.0...mcp-utils-v0.11.1)
(2026-11-26)


### Bug Fixes

* **mcp-ui:** shared project card for create-project and create-branch
([#578](#578))
([efe189f](efe189f))
</details>

<details><summary>mcp-server-supabase: 0.20.0</summary>

##
[0.20.0](mcp-server-supabase-v0.19.0...mcp-server-supabase-v0.20.0)
(2026-11-26)


### Features

* **debugging:** add project issues DEBUG-311
([#546](#546))
([01f8021](01f8021))
* **mcp-server-supabase:** add optional schemas parameter to
generate_typescript_types
([#592](#592))
([7532f53](7532f53))


### Bug Fixes

* **debugging:** link docs once per issue in get_issues
([#610](#610))
([74801d8](74801d8))
* **mcp-server-supabase:** detect import maps uploaded with a ./ prefix
([#591](#591))
([6b8f4dc](6b8f4dc))
* **mcp-server-supabase:** keep a declined or cancelled SQL confirmation
final ([#581](#581))
([03afe8e](03afe8e))
* **mcp-server-supabase:** match Studio's notebook row_limit and clarify
skip and blank-input messages
([#593](#593))
([ad07f1b](ad07f1b))
* **mcp-server-supabase:** skip cost confirmation for $0 projects on
clients without forms
([#608](#608))
([50cfc37](50cfc37))
* **mcp-server-supabase:** stop reusing a removed import map on edge
function redeploy ([#588](#588))
([56093a6](56093a6))
* **mcp-ui:** shared project card for create-project and create-branch
([#578](#578))
([efe189f](efe189f))
* **mcp:** confirm UPDATEs without WHERE that follow a comment and set a
dollar-quoted value ([#612](#612))
([468907a](468907a))
* **mcp:** confirm UPDATEs without WHERE that use inheritance syntax
([#565](#565))
([687b3ee](687b3ee))
* **mcp:** confirm UPDATEs without WHERE when a column name ends in
where ([#557](#557))
([57fa34b](57fa34b))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: supabase-releaser[bot] <223506987+supabase-releaser[bot]@users.noreply.github.com>
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.

deploy_edge_function reuses a removed import map on redeploy

2 participants