Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
2 tasks done
nhandyal opened this issue Jan 24, 2025 · 0 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@nhandyal
Copy link

nhandyal commented Jan 24, 2025

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

@nhandyal nhandyal added the bug Something isn't working label Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant