firebase-tools
firebase-tools copied to clipboard
Content-Disposition Header Error with Non-Standard Whitespace in Filenames in Storage Emulator
[REQUIRED] Environment info
firebase-tools: 13.4.0
Platform: macOS 14.2.1, M2
[REQUIRED] Test case
This can be reproduced in the emulator UI tool itself without any additional code.
[REQUIRED] Steps to reproduce
- Run
firebase emulators:start - Capture a screenshot in macOS (cmd + shift + 3)
- Open emulator UI, go to Storage, click 'Upload file', select screenshot that was captured in step 2
- After upload, click on the file.
[REQUIRED] Expected behavior
You should be able to view a preview of the uploaded image.
[REQUIRED] Actual behavior
After I select the image file the preview image in the right side panel shows a broken image and the emulators crash.
Error log shows this
[debug] [2024-03-05T03:27:42.889Z] TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["Content-Disposition"]
at ServerResponse.setHeader (node:_http_outgoing:655:3)
at sendFileBytes (/Users/x/Documents/GitHub/x/node_modules/firebase-tools/lib/emulator/storage/apis/shared.js:20:9)
at /Users/x/Documents/GitHub/x/node_modules/firebase-tools/lib/emulator/storage/apis/firebase.js:101:47
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[error]
[error] Error: An unexpected error has occurred.
Upon investigating, it looks like adding the filename to the Content-Disposition header in this commit caused the bug to start occurring.
It took me a while to realize there is something about the automated screenshot filenames that is causing the issue, but as best as I can tell, that's what it is.
Hey @peteshilling, thanks for the detailed report and for sharing your observations. I was able to reproduce this issue. I’ll notify our engineering team about this so they can take a look.
Thank you, @aalej. It's one of those bugs that isn't a big deal once you know what is happening (just avoid using screenshot files when testing), but at first it looked like a much bigger issue and took some time to narrow down.
Im having the same issue, except its happening when i await bucket.file(filePath).download({ destination: tempFilePath }); within a cloud function. The function is onFinalize of storage object.
[debug] [2024-05-03T04:27:42.785Z] TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["Content-Disposition"]
at ServerResponse.setHeader (node:_http_outgoing:651:3)
at sendFileBytes (/X/services/firebase/node_modules/.pnpm/[email protected]/node_modules/firebase-tools/lib/emulator/storage/apis/shared.js:19:9)
at /X/services/firebase/node_modules/.pnpm/[email protected]/node_modules/firebase-tools/lib/emulator/storage/apis/gcloud.js:88:47
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[error]
[error] Error: An unexpected error has occurred.