cli icon indicating copy to clipboard operation
cli copied to clipboard

Functions which import from parent directory fail to deploy using api flag

Open sweatybridge opened this issue 10 months ago • 0 comments

Describe the bug https://github.com/supabase/cli/issues/2533#issuecomment-2801993444

To Reproduce

  1. Create supabase/functions/slug/index.ts
import "jsr:@supabase/functions-js/edge-runtime.d.ts";
import { handler } from "../../../../common/index.ts";

console.log("Hello from Functions!");

Deno.serve(handler);
  1. Create ../common/index.ts
export const handler = async (req) => {
  const { name } = await req.json()
  const data = {
    message: `Hello ${name}!`,
  }

  return new Response(
    JSON.stringify(data),
    { headers: { "Content-Type": "application/json" } },
  )
}
  1. Run supabase functions deploy --use-api and observe error
Uploading asset (update): supabase/functions/slug/index.ts
failed to read file: open ../common/index.ts: invalid argument
Try rerunning the command with --debug to troubleshoot the error.
exit status 1

Expected behavior Deploying functions that import from parent directory should also work.

The current workaround is to use docker deploy.

System information

  • Version of OS: macOS
  • Version of CLI: v2.22.3

Additional context Since our bundle API doesn't support parent directories, we have to change the working directory to the actual repo path rather than the current default of ../supabase. This will be a large refactor but also helps with setting more consistent paths in other places like the seed table.

sweatybridge avatar Apr 21 '25 09:04 sweatybridge