Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storage Upload Error Typescript Issue #442

Open
2 tasks done
mkmoisen opened this issue Mar 12, 2024 · 0 comments
Open
2 tasks done

Storage Upload Error Typescript Issue #442

mkmoisen opened this issue Mar 12, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@mkmoisen
Copy link

mkmoisen commented Mar 12, 2024

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • 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.

@mkmoisen mkmoisen added the bug Something isn't working label Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant