Skip to content

Storage.from.exists throws an error when the file doesn't exist in the bucket #1363

Open
@nhandyal

Description

@nhandyal

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

The storage.from().exists() method returns false AND an exception if the file doesn't exist. This doesn't seem like correct behavior. If the cause of the error was only that the file doesn't exist, this api should return data: false, error: null. The error should only be set if it is a true error.

To Reproduce

import { createClient } from "@supabase/supabase-js";
const client = createClient(url, key)

// ensure my_bucket exists, but foo.txt does not. 
const r = await client.storage.from("my_bucket").exists("foo.txt")
console.log(r);

// output
{
  data: false,
  error: StorageUnknownError: {}
      at <anonymous> (/workspaces/demo/node_modules/@supabase/storage-js/src/lib/fetch.ts:36:12)
      ...
}

Expected behavior

Result should not contain an error simply if the file doesn't exist. Error should only be set if there is a true error.
If the file doesn't exist

{
  data: false,
  error: null
}

Screenshots

System information

  • OS: [e.g. macOS, Windows]
  • Browser (if applies) [e.g. chrome, safari]
  • Version of supabase-js: [e.g. 6.0.2]
  • Version of Node.js: [e.g. 10.10.0]

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions