You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Node http adapter drops the filename of FormData files with an empty name, so they arrive as text fields #11331
With the Node http adapter, a native FormData file entry whose name is an empty string is serialized without a filename parameter. formDataToStream only writes filename when value.name is truthy, so the part goes out as:
Multipart parsers treat a part without filename as a plain text field, so the server receives a string instead of a file, and binary content is decoded as UTF-8. axios's own multipart serializer on the fetch path (formDataToBlob, used when maxBodyLength is set) writes filename="" for the same entry, and its test expects the parsed upload to come back as a file named ''.
Example code
importhttpfrom'http';importaxiosfrom'axios';constserver=http.createServer((req,res)=>{constchunks=[];req.on('data',(c)=>chunks.push(c));req.on('end',async()=>{constform=awaitnewResponse(Buffer.concat(chunks),{headers: {'Content-Type': req.headers['content-type']},}).formData();console.log(form.get('upload'));// '�\u0000' (a string)res.end();server.close();});});server.listen(0,async()=>{constform=newFormData();form.append('upload',newBlob([newUint8Array([0xff,0x00])]),'');awaitaxios.post(`http://localhost:${server.address().port}/`,form,{adapter: 'http'});});
Expected behavior
The part carries filename="" and the server gets a File named '' containing the bytes ff 00.
Actual behavior
The part has no filename, the server gets the string '�\u0000', and the 0xff byte is lost.
Verified: added a unit test with name: ''; npm run test:vitest:unit -- tests/unit/helpers/formDataToStream.test.js → all passed (including the new case). Can PR with ai-assisted if useful.
Activity
fix(http): keep filename parameter for files with an empty name
fix(http): keep filename parameter for files with an empty name
hamarshehmhmd commentedon Nov 6, 2026
Agreed — empty-string filenames should still serialize as
filename="", matchingformDataToBlob/ the fetch path.Root cause:
lib/helpers/formDataToStream.jsuses a truthy check:So
name: ''skips the parameter and multipart parsers treat the part as a text field.Fix:
Verified: added a unit test with
name: '';npm run test:vitest:unit -- tests/unit/helpers/formDataToStream.test.js→ all passed (including the new case). Can PR withai-assistedif useful.fix(http): keep filename parameter for files with an empty name