supabase-js icon indicating copy to clipboard operation
supabase-js copied to clipboard

fix(storage)!: do not throw error when file does not exist in exists method

Open mandarini opened this issue 3 months ago • 0 comments

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

The storage.from().exists() method returns both data: false and a StorageUnknownError when checking for a non-existent file, treating the 404 response as an error condition.

What is the new behavior?

The method now correctly returns { data: false, error: null } when a file doesn't exist (404/400 status codes), while still properly reporting actual errors (auth failures, network issues, etc.).

Additional context

  • Issue #1363
  • 404 and 400 status codes are valid responses indicating non-existence, not error conditions
  • Added test assertion to verify error is null when file doesn't exist
  • Related: https://github.com/supabase/supabase-js/pull/1745

Breaking change

This is a breaking change, and it can be added in the v3 planning.

mandarini avatar Nov 06 '25 14:11 mandarini