Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix: improve error handling for upload cases in storage explorer (#43054)

Ivan Vasilova7e0a428feb2
diff --git a/apps/studio/state/storage-explorer.tsx b/apps/studio/state/storage-explorer.tsx
index 85e4eb938e7..4e98579275d 100644
--- a/apps/studio/state/storage-explorer.tsx
+++ b/apps/studio/state/storage-explorer.tsx
@@ -1215,7 +1215,7 @@ function createStorageExplorerState({
const status = error.originalResponse?.getStatus()
switch (status) {
- case 415:
+ case 415: {
// Unsupported mime type
toast.error(
capitalize(
@@ -1227,20 +1227,38 @@ function createStorageExplorerState({
}
)
break
- case 413:
+ }
+ case 413: {
// Payload too large
toast.error(
`Failed to upload ${file.name}: File size exceeds the bucket file size limit.`
)
break
- case 409:
+ }
+ case 409: {
// Resource already exists
toast.error(`Failed to upload ${file.name}: File name already exists.`)
break
- case 400:
- // Invalid key
- toast.error(`Failed to upload ${file.name}: File name is invalid`)
+ }
+ case 400: {
+ const responseBody = error.originalResponse?.getBody()
+ if (typeof responseBody === 'string') {
+ if (responseBody.includes('Invalid key:')) {
+ toast.error(`Failed to upload ${file.name}: File name is invalid.`)
+ break
+ }
+
+ if (responseBody.includes('Invalid Compact JWS')) {
+ toast.error(`Failed to upload ${file.name}: Invalid Compact JWS.`)
+ break
+ }
+ }
+ // if it's not handled by the two ifs, fallthrough to the default case which shows the generic error message
+ }
+ default: {
+ toast.error(`Failed to upload ${file.name}: ${error.message}`)
break
+ }
}
} else {
toast.error(`Failed to upload ${file.name}: ${error.message}`)