storage icon indicating copy to clipboard operation
storage copied to clipboard

Response error object other than the expected StorageError is returned.

Open gonta1026 opened this issue 2 years ago • 6 comments

Bug report

Describe the bug

A non-StorageError response error object is returned.

To Reproduce

  const { error } = await supabase.storage.from(BUCKET.ITEM).upload(path, image.file, {
    upsert: true,
  })
  // expect: StorageError | null
  // but returned error : {statusCode: '400', error: 'Invalid Input', message: 'The object name contains invalid characters'}
  if (error instanceof StorageError) {
    // Not Reachable...
    console.log({ error })
  }

  1. upload image file
  2. return validation error (Because it contains Japanese strings)
  3. Error response returns with no expectation(example: {statusCode: '400', error: 'Invalid Input', message: 'The object name contains invalid characters'}

Expected behavior

Newly implement a response or expected response structure with a StorageError structure.

System information

  • OS: macOS m2
  • Browser chrome
  • Version of "@supabase/supabase-js": "^2.2.3",
  • Version of Node.js: v18.12.0

gonta1026 avatar Jan 29 '23 14:01 gonta1026

Duplicated with https://github.com/supabase/storage-api/issues/133

Xuanwo avatar May 02 '23 16:05 Xuanwo

This is not a duplicate of #133 This ticket is about the typescript object StorageError. The response received in "error" contains different members than the definition of StorageError.

I.e. the "error" member of the received payload is missing in StorageError.

groyGetaway avatar Jul 27 '23 15:07 groyGetaway

I am having the same issue. I try to upload a file called css.png and it says 'The object name contains invalid characters'. Not sure if it's my policies on my bucket, but css.png is definitely valid.

adamjjones avatar Jul 30 '23 05:07 adamjjones

I'm having the same issue and it cripples my project as suddenly images are not uploaded.

shalawfatah avatar Aug 27 '23 17:08 shalawfatah

I've the same problem as the original author described. I think the other comments are not related to the original issue, this is just a error type problem.

onalv avatar Oct 13 '23 20:10 onalv

https://github.com/supabase/storage/blob/8fa98fab7716dccefb257b5fad8c3a9ba567df05/src/storage/object.ts#L50-L57

https://github.com/supabase/storage/blob/8fa98fab7716dccefb257b5fad8c3a9ba567df05/src/storage/limits.ts#L56-L66

https://github.com/supabase/storage/blob/8fa98fab7716dccefb257b5fad8c3a9ba567df05/src/storage/limits.ts#L33-L42

zhyd1997 avatar Dec 08 '23 09:12 zhyd1997