usebruno / bruno

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

Error generating code snippet #1584

Open eyayaw opened 7 months ago

eyayaw commented 7 months ago

Hi there,

Bruno's (v 1.9.0) code generation fails on some API entries for me. It has been working for me since the feature was introduced. The only change I made was recently using the .env feature for environment variables. My environment variables setup works fine.

oklaiss commented 6 months ago

I'm seeing this as well on v1.12.1. It was working on v1.10.0

ujaehrig commented 5 months ago

Updated to v1.13.1 The error still occurs. Is there any way to see, what the error is?

ponsfrilus commented 4 months ago

Updated to v1.16.1, but still have the issue. Toggling developer tools don't help that much: image

sanjai0py commented 4 months ago

The code generation may fail during any step. To further investigate the issue please provide a sanitized version of the .bru file alongside.

ernstki commented 3 months ago

Attempted with 1.12.3 and the latest as of this writing, 1.17.0, on Intel Mac. The earlier version reports an error similar to the one reported here. The up-to-date 1.17 version does not have the issue—for my particular use case.

Sanitized collection.bru and RequestName.bru, including the output from the dev console in 1.12.3 below.

# collection.bru
auth {
  mode: bearer
}

auth:bearer {
  token: SuperSecretTokenString
}
# environments/prod.bru
vars {
  api: https://the.internal.url/gitlab/api/v4
}
# Search.bru
meta {
  name: Search
  type: http
  seq: 3
}

get {
  url: {{api}}/search?scope=blobs&search="module load"
  body: none
  auth: none
}

query {
  scope: blobs
  search: "some search query"
}

Screenshot of dev console in 1.12.3

Screenshot of the backtrace in the dev console with 1.12.3

The current 1.17.0 build does not produce any error in the Chrome/Electron console. Hard to say if my problem was the exact same as that of @eyayaw's original report, though.

See if updating to a newer build fixes it, regardless

Either way—regardless of what error message shows up in the Chrome/Electron dev console for you—if you are somewhere between 1.12 and 1.17 now, I'd recommend trying the latest build to see if the error goes away.

arnaduga commented 3 months ago

Same issue with v1.18.0 on Windows image

blazindrop commented 3 months ago

I had the same issue. The cause was my POST request was sending URL parameters for the payload. When I moved them to use Body multipart form or form url coded the export worked.

merc1er commented 3 months ago

@helloanoop This now displays "Oops! Something went wrong" when trying to generate code on version 1.19.0: image

Bonnev commented 3 months ago

Hey guys. I guess it gives different errors in different cases. My case was the "validation failed" and it was an issue with the GET params - they had spaces (which worked fine when sending the request, but failed for the export). When I encoded it (e.g. via https://www.urlencoder.io/) it worked.

Note: some unencoded values don't even work when sending the request.

So what should be fixed for this specific case is to allow unencoded values in the params and automatically encode them when sending the request and when exporting.

flav1972 commented 2 months ago

for me on windows (v1.18.0). error unknown keyword "afterRequest" image as @arnaduga above.

tadams1138 commented 1 month ago

Similar problem but mentions "Cannot read properties of undefined (reading 'externalSecrets')". v1.19.0 of Bruno image image

Its-treason commented 1 month ago

Similar problem but mentions "Cannot read properties of undefined (reading 'externalSecrets')". v1.19.0 of Bruno image image

Update your installation, this was fixed with 1.20.0

tadams1138 commented 1 month ago

Thanks @lts-treason ! That fixed it.

mehmoodak commented 1 month ago

Updated to v1.23.1 and still facing error while generating code.

TypeError: Cannot read properties of undefined (reading 'filter')
    at createPostData (557-d94615abd63cd33c.js:1:445738)
    at buildHarRequest (557-d94615abd63cd33c.js:1:446135)
    at GenerateCodeItem_CodeView (557-d94615abd63cd33c.js:1:447320)
    at Xh (framework-80ea8c0f440c6a32.js:9:60991)
    at dj (framework-80ea8c0f440c6a32.js:9:72858)
    at x (framework-80ea8c0f440c6a32.js:9:120345)
    at Vk (framework-80ea8c0f440c6a32.js:9:99131)
    at framework-80ea8c0f440c6a32.js:9:98998
    at Jk (framework-80ea8c0f440c6a32.js:9:99005)
    at Fk (framework-80ea8c0f440c6a32.js:9:96095)
sanjai0py commented 1 month ago

Hey @mehmoodak, will it be possible for you to share the .bru file?

mehmoodak commented 3 weeks ago

@sanjai0py not sure what's changed but its working fine now 🤷‍♂️