[BUG] filePaths.forEach is not a function when using multipart-form body with file type
BRU-5061
I have checked the following:
- [x] I have searched existing issues and found nothing related to my issue.
This bug is:
- [x] Making Bruno unusable for me.
- [ ] Slowing me down but I'm able to continue working.
- [ ] Annoying.
- [ ] This feature was working in a previous version but is broken in the current release.
Bruno version
4.3.0
💻 Operating System
Linux
Specific OS Version / Distro
Running via Docker
🐞 Describe the bug
For multipart-form types, files cannot be added to the formdata object. I have tried all sorts of paths (absolute path (relative to root), relative to collection root, relative to folder, moved the file to another path entirely), but the error message to me would indicate that there is an error in bruno as opposed to the collection.
📝 Steps to reproduce
- Use the below collection (or download this repo and navigate to the tests directory and execute the
./run-tests.shscript) - Run it, no backend service needed, the error also occurs when there is no backend running
📁 Collection to reproduce
Folder structure: opencollection.yml |--test/ |--folder.yml |--test.yml
opencollection.yml
# yaml-language-server: $schema=https://schema.opencollection.com/opencollection/v1.0.0.json
opencollection: 1.0.0
info:
name: Demo
version: 1.0.0
authors:
- name: janishutz
email: [email protected]
bundled: false
extensions:
bruno:
ignore:
- node_modules
- .git
items:
- info:
type: http
folder.yml
# yaml-language-server: $schema=https://schema.opencollection.com/opencollection/v1.0.0.json#/$defs/Folder
info:
name: assets
type: folder
seq: 1
test.yml
# yaml-language-server: $schema=https://schema.opencollection.com/opencollection/v1.0.0.json#/$defs/HttpRequest
info:
type: http
name: Upload a valid file
seq: 1
http:
method: PUT
url: "{{baseUrl}}/assets/upload/{{assets-1}}"
body:
type: multipart-form
data:
- name: file
type: file
value: ./ok-asset.json
disabled: false
runtime:
assertions:
- expression: res.status
operator: eq
value: "201"
The above is the test I am running, the variables exist and work with the entire rest of the test suite, but only the file upload tests fail.
📷 Screenshots/Live demo link
The complete error message is filePaths.forEach is not a function, even in the generated report.
Thanks for the detailed report and the sample collection @janishutz. I was able to reproduce it: when a file field is written as a single path (value: ./ok-asset.json), the upload fails with filePaths.forEach is not a function. Saving the request in the app also clears the file, so later sends go through with no file attached.
Until this is fixed, writing the file as a list works:
value:
- ./ok-asset.json
There are two open PRs for this (#9849 and #9850). We'll test them and update here. Follow those PRs for updates.
@aditya-bruno thanks for the reply and I did not consider this workaround as an option, so thanks! (It should have been obvious from the error message in retrospect...). I had seen the PRs as well