bruno
bruno copied to clipboard
bruno-cli - graphql requests - Parse error on JSON when using a environment variable in a non string field
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
2.14.1
Operating System
Windows 11 26100.6899
Describe the bug
Steps to reproduce:
- create a graphql request as specified in the attached file
- run your request through bruno-cli
- bruno is sending the request with the numeric and structured variables replaced by their current value
- run your collection using the command line : bru run . --insecure --env MyAPIEnv
Observed behaviour:
- Error raised at the pre request stage : (Expected property name or '}' in JSON at position 23 (line 2 column 22))
It seems that the variables have not been replaced by their values before the graphql query syntax validation.
.bru file to reproduce the bug
Screenshots/Live demo link
Query sent through bruno
Query sent through bruno cli
@Pragadesh-45 Can you repro this?
@helloanoop Yes, I can reproduce this issue in the CLI
Hi, @helloanoop, @Pragadesh44-Bruno,
I don't know if it oculd help, but after reviewing the bruno-cli sources, it seems to me that the error is due to the fact that the graphql request variables is parsed before the variables interpolation.
- graphql request variables parsing: https://github.com/usebruno/bruno/blob/9d3c8b2401f2e75ae33d91191fa9ea03a37a0984/packages/bruno-cli/src/runner/prepare-request.js#L371
- Called from: https://github.com/usebruno/bruno/blob/9d3c8b2401f2e75ae33d91191fa9ea03a37a0984/packages/bruno-cli/src/runner/run-single-request.js#L128
- While vars interpolation happens here: https://github.com/usebruno/bruno/blob/9d3c8b2401f2e75ae33d91191fa9ea03a37a0984/packages/bruno-cli/src/runner/run-single-request.js#L225