Supabase Storage: user sees files of another folder
Storage policy allows you to read objects from the folder adjacent to the user folder.
How to identify the source of the problem
Check the policy conditions and functions of storage.foldername and the format of the ids in paths.
Compare the result for the authorized and unauthorised user, project name and exact error code.
Repair steps
Replace non-precision LIKE with a safe comparison of the folder segment with auth.uid() and check all operations.
How to Test Solution
Two accounts read only their own files and the attempt to change the folder is rejected.
Security and restrictions
Change permissions and scheme first on test data with backup. Do not put service role in your browser.