Skip to content

Supabase Storage errorSupabase Storage: InvalidKey, the specified key is invalid

InvalidKey is the Supabase Storage error, status 400, for a file path with a character Storage doesn’t allow. File names allow letters A to Z, digits and some punctuation, so accents, emoji, # and % fail. The path usually comes from the user’s file name.

Short answer

Don’t use the user’s file name as the path. Build the path from the user ID and a random ID plus a cleaned extension, upload with that, and save the original name in your own table so you can show it later.

Rather not fix it yourself? App Fix Ticket starts with a fixed-price diagnosis, then a fixed price for the fix before any fix work.

Why the key is invalid, and the fix

  1. 01

    The file name has accents, emoji or other scripts

    “The specified key is invalid.” Supabase docs, Storage error codes (InvalidKey)

    A name like résumé.pdf, a photo named with an emoji, or a file name in Arabic or Chinese fails, because Storage allows only plain Latin letters, digits and some punctuation.

  2. 02

    The name has a character outside the allowed list

    “File names can only include the following characters: Alphanumeric: A-Z, a-z, 0-9” Supabase docs, Storage limits (File name restrictions)

    Characters such as #, %, [ ], { }, < >, ^, ~ and | aren’t on the list. Spaces, &, ?, + and = are allowed. A slash is read as a folder, so a name with a slash creates folders you didn’t mean to make.

  3. 03

    The path comes straight from user input

    Generate the path instead, and keep the display name in a column next to the path.

    const ext = file.name.includes('.') ? file.name.split('.').pop().toLowerCase().replace(/[^a-z0-9]/g, '') : '';
    const path = `${user.id}/${crypto.randomUUID()}${ext ? '.' + ext : ''}`;
    const { error } = await supabase.storage.from('uploads').upload(path, file);
    if (!error) await supabase.from('files').insert({ path, name: file.name });
  4. 04

    A move or copy uses the old name

    move() and copy() take a new path too, so build that path the same way. Renaming a file to the user’s new title brings the same error back.

Checked against the vendor’s docs on : Supabase docs: Storage error codes; Supabase docs: Storage limits.

Rather hand it over?

Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.

“Very responsive, attentive to fixing bugs, and completed the project as needed! Thank you!”
A buyer in the United States, July 2022. Shopify on Fiverr
All 127 Fiverr reviews

Related: Supabase Storage EntityTooLarge · Supabase Storage bucket not found · Supabase Storage bucket is public · Supabase Storage MIME type error · Supabase Storage resource already exists

Questions

More on this error

Can I just encode the file name?

Percent-encoding adds %, which isn’t on the allowed list either. A generated ID is simpler and also avoids two users uploading files with the same name.

Will users still see the original file name?

Yes, if you save it in your table and show it in the app. To keep it on download, pass the name in the download option when you create a signed URL.

Can you fix it for me?

If one bug is the whole problem, the App Fix Ticket covers it: a written diagnosis first, then the fix. If the app has more going on, the Launch Check is a written check of the whole app. Each issue found is rated critical, high, medium or low, with where it is and how it was confirmed. No issues worth fixing, no charge. If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way. This applies to the first 10 Launch Checks bought after October 30, 2026.

A different error?

Describe it and get a written quote

Send the error and what you were doing. You get a written scope, a fixed price and a timeline; Simon replies by email, usually within one business day.