bruno icon indicating copy to clipboard operation
bruno copied to clipboard

bruno-cli - graphql requests - Parse error on JSON when using a environment variable in a non string field

Open r321st opened this issue 1 month ago • 2 comments

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

ShowDefect.zip

Screenshots/Live demo link

Query sent through bruno

Image

Query sent through bruno cli

Image

r321st avatar Nov 12 '25 11:11 r321st

@Pragadesh-45 Can you repro this?

helloanoop avatar Nov 12 '25 13:11 helloanoop

@helloanoop Yes, I can reproduce this issue in the CLI

Pragadesh44-Bruno avatar Nov 12 '25 18:11 Pragadesh44-Bruno

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

r321st avatar Nov 18 '25 13:11 r321st