usebruno / bruno

Opensource IDE For Exploring and Testing Api's (lightweight alternative to postman/insomnia)
https://www.usebruno.com/
MIT License
21.54k stars 1.01k forks source link

[Postman] Importing request with "formdata" of type "file" fails silently #2462

Closed darylteo closed 1 week ago

darylteo commented 1 week ago

I have checked the following:

Describe the bug

index.html:1 Uncaught (in promise) Error: Error invoking remote method 'renderer:import-collection': TypeError: Cannot read properties of undefined (reading 'includes')

As per https://schema.postman.com/collection/json/v2.1.0/draft-07/collection.json:683, a formdata body may have "key:value" attributes for type "string", but "key:src" instead for type "file".

.bru file to reproduce the bug

{
    "info": {
        "_postman_id": "redacted",
        "name": "redacted",
        "description": "redacted",
        "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
        "_exporter_id": "",
        "_collection_link": ""
    },
    "item": [
        {
            "name": "Profile",
            "item": [
                {
                    "name": "Update profile avatar",
                    "request": {
                        "auth": {
                            "type": "bearer",
                            "bearer": [
                                {
                                    "key": "token",
                                    "value": "{{AUTH_TOKEN}}",
                                    "type": "string"
                                }
                            ]
                        },
                        "method": "POST",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json",
                                "type": "text"
                            },
                            {
                                "key": "Content-Type",
                                "value": "application/json",
                                "type": "text"
                            }
                        ],
                        "body": {
                            "mode": "formdata",
                            "formdata": [
                                {
                                    "key": "avatar",
                                    "type": "file",
                                    "src": "/Users/darylteo/Downloads/demo-images/001.jpg"
                                }
                            ]
                        },
                        "url": {
                            "raw": "{{API_URL}}/auth/profile/avatar",
                            "host": [
                                "{{API_URL}}"
                            ],
                            "path": [
                                "auth",
                                "profile",
                                "avatar"
                            ]
                        },
                        "description": ""
                    },
                    "response": [

                    ]
                }
            ]
        }
    ]
}

Screenshots/Live demo link

https://imgur.com/XmfbmLO

helloanoop commented 1 week ago

The PR is merged.

Thanks for taking care of this @sanjai0py ! This is set to go out in the upcoming v1.20.0 release.