Skip to content

feat(storage): parity exists route - #821

Merged
Tr00d merged 5 commits into
supabase:masterfrom
diegofesanto:feature/storage-exists
Dec 3, 2026
Merged

Tr00d merged 5 commits into
supabase:masterfrom
diegofesanto:feature/storage-exists

Conversation

@diegofesanto

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

feature

What is the current behavior?

What is the new behavior?

  • Parity: add exists route

Additional context

Add any other context or screenshots.

@Tr00d

Tr00d commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

@diegofesanto The pipeline fails, mostly because the capability key isn't recognised.
I've also run a quick review with Claude, and here are the findings:

  1. The implementation contradicts its own docs and swallows real errors.
  • StorageFileApi.cs catches every SupabaseStorageException and returns false.
  • The XML doc on IStorageFileApi says false only for NoSuchKey or a 404 with no error code, and that InvalidJWT, NoSuchBucket and network errors throw.
  • As written, an expired token, a missing bucket or a 403 all report "file doesn't exist". For something like if (!await Exists(x)) upload, that can cause an overwrite or a wrong decision.
  • It's also the thick-client behavior your SDK principles warn against: the service's error code decides the answer, so the client should map only the specific "not found" code.
  • Fix: catch with a filter on the not-found reason, and let everything else propagate.
  1. The tests don't cover the cases that matter.
  • The contract test for "false" returns 404 with a made-up {"name":"a.png"} body. That isn't a real NoSuchKey payload, and the 404-without-code path is untested too.
  • There is no test that 401, a missing bucket or a 500 throws. Such a test would fail today, per finding 1.
  • The CancellationToken isn't forwarded: Info(path) has no token parameter, so Exists accepts one and ignores it. Either plumb it through Info or drop it from the signature.
  • The names don't follow the repo's Method_ShouldX_GivenY convention, and "Exising" is misspelled twice.
  1. The capability key is unverified.
  • storage.file_buckets.exists isn't in sdk-compliance.yaml. The neighbors there are file_info, list_files and so on.
  • It may be a new registry key. Check it against the registry before merging, given what happened with the keys in feat(auth): parity oauth authorisation #818.
  1. supabase/.gitignore gained the same four lines as in feat(auth): parity oauth authorisation #818.
  • They look like local tooling artifacts and aren't part of the feature. Both PRs would add them, so ask for them to be dropped from both.

Smaller items

  • Exists is written imperatively: a mutable bool exists set inside try and catch. Once the filter from finding 1 exists, try { return await Info(path) != null; } catch (...) when (...) { return false; } reads better.
  • Info doesn't escape the path. That predates this PR, but Exists inherits it.
  • The PR body is the empty template, and the PR is not marked draft.

diegofesanto and others added 3 commits November 28, 2026 11:06
# Conflicts:
#	packages/Storage/Storage/PublicAPI.Unshipped.txt
…ure/storage-exists

- fix stuffs related to code review
# Conflicts:
#	packages/Storage/Storage/PublicAPI.Unshipped.txt
Merge origin/master. Rename to ExistsAsync, add ConfigureAwait(false),
restore the interface file to a one-member addition, drop the unrelated
supabase/.gitignore change, and rewrite the tests to the repo style.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@Tr00d

Tr00d commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

@diegofesanto I saw there were still conflicts and points I raised were partially addressed:
I pushed the remaining fixes directly on your branch. Here are some details:

Change Why
Merged master, resolved the conflicts The branch conflicted with PublicAPI.Unshipped.txt, IStorageFileApi.cs and StorageFileApi.cs.
IStorageFileApi.cs restored from master, then ExistsAsync added The file had been reformatted wholesale (namespace style, BOM, re-indenting), which hid the actual change.
Exists renamed to ExistsAsync New async public methods take the Async suffix.
ConfigureAwait(false) on the new await Required on every await in library code.
Removed the unused default value on the private Info overload Nothing used it.
wrapped in CDATA Required for examples.
Dropped the supabase/.gitignore additions They were local tooling artifacts and not part of this feature.
Tests rewritten to the repo style Inline assertions, no hand-written fake handler (the network failure is now an unreachable port), no magic status codes, unique name in the E2E not-found test.

@Tr00d
Tr00d merged commit 4b9d77c into supabase:master Dec 3, 2026
16 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants