Storage Upload Error Typescript Issue
Bug report
- [x] I confirm this is a bug with Supabase, not with my own application.
- [x] I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
The error returned from supabase.storage.from(...).upload has a typescript issue. It it supposed to be returning a StorageError which should have a status as a number, but it seems to be returning some other exception which instead contains a statusCode as a string.
To Reproduce
Upload a file to a location where a file already exists.
const { data, error } = await supabase.storage.from(
'foos'
).upload(
'bar.txt',
someFile
);
if (error) {
console.log('error is', error);
}
if (error && error.statusCode !== "409") {
// 409 means we've already uploaded this photo
throw error;
}
Expected behavior
Logging the error shows:
error is {
statusCode: "409",
error: "Duplicate",
message: "The resource already exists"
}
However, error.statusCode results in the following typescript error:
Property 'statusCode' does not exist on type 'StorageError'.
The upload is supposed to return a StorageError
StorageError however has no such statusCode, so it seems that it is not returning a StorageError.
Seconding this. The closest type I see in errors.ts is the StorageApiError type but it has a status property, not statusCode like we see in the error object.