[GH-ISSUE #3675] [bug]: PARSING_ERROR Unable to parse variables inside request body #1266

Closed
opened 2026-03-16 19:32:11 +03:00 by kerem · 6 comments
Owner

Originally created by @yvz5 on GitHub (Dec 19, 2023).
Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/3675

Originally assigned to: @jamesgeorge007 on GitHub.

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

When I use a variable inside the request body I get the following error:

  PARSING_ERROR Unable to parse -
  {"url": "http://<<testapihost>>:8081"}
   (ENV_EXPAND_LOOP)
  REQUEST_ERROR Invalid URL

my env.json is

{
  "name": "test-variables",
  "variables": [
    {
      "key": "testapihost",
      "value": "localhost"
    }
  ]
}

the part where the collection has the variable:

"body": {
                        "contentType": "application/json",
                        "body": "{\"url\": \"http://<<testapihost>>:8081\"}"
                    },

Steps to reproduce

1- create an env variable
2- create a request
3- add this env variable into the body
4- run hopp test -e env.json collection.json

Environment

Production

Version

Local

Originally created by @yvz5 on GitHub (Dec 19, 2023). Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/3675 Originally assigned to: @jamesgeorge007 on GitHub. ### Is there an existing issue for this? - [X] I have searched the existing issues ### Current behavior When I use a variable inside the request body I get the following error: ``` PARSING_ERROR Unable to parse - {"url": "http://<<testapihost>>:8081"} (ENV_EXPAND_LOOP) REQUEST_ERROR Invalid URL ``` my env.json is ``` { "name": "test-variables", "variables": [ { "key": "testapihost", "value": "localhost" } ] } ``` the part where the collection has the variable: ``` "body": { "contentType": "application/json", "body": "{\"url\": \"http://<<testapihost>>:8081\"}" }, ``` ### Steps to reproduce 1- create an env variable 2- create a request 3- add this env variable into the body 4- run `hopp test -e env.json collection.json` ### Environment Production ### Version Local
kerem 2026-03-16 19:32:11 +03:00
  • closed this issue
  • added the
    bug
    cli
    labels
Author
Owner

@jamesgeorge007 commented on GitHub (Dec 20, 2023):

Hi, please share a sample collection and environment (if different from above) export that can be used to reproduce the issue.

<!-- gh-comment-id:1864845920 --> @jamesgeorge007 commented on GitHub (Dec 20, 2023): Hi, please share a sample collection and environment (if different from above) export that can be used to reproduce the issue.
Author
Owner

@yvz5 commented on GitHub (Dec 21, 2023):

The problem I have is to use variables for the url to send and also put those variables inside the body. the following example shows the error:

bug/echo/should return 200 reported errors:
  PARSING_ERROR Unable to parse -
  {
   "first_name": "<<first-name>>" 
  ,"last-name": "<<lastname>>" 
  } (ENV_EXPAND_LOOP)

a simplified version of the collection:

{
    "v": 1,
    "name": "bug",
    "folders": [
        {
            "v": 1,
            "name": "echo",
            "folders": [],
            "requests": [               
                {
                    "v": "1",
                    "name": "should return 200",
                    "endpoint": "https://echo.hoppscotch.io",
                    "method": "POST",
                    "headers": [],
                    "params": [],
                    "auth": {
                        "authType": "none",
                        "authActive": true
                    },
                    "body": {
                        "contentType": "application/json",
                        "body": "{\n \"first_name\": \"<<first-name>>\" \n,\"last-name\": \"<<lastname>>\" \n}"                        
                    },
                    "preRequestScript": "",
                    "testScript": ""
                }                
            ]
        }],
    "requests": []
}

env.json

{
  "name": "bug",
  "variables": [
    {
      "key": "first-name",
      "value": "james"
    },
    {
      "key": "lastname",
      "value": "bond"
    }
  ]
}
<!-- gh-comment-id:1865820901 --> @yvz5 commented on GitHub (Dec 21, 2023): The problem I have is to use variables for the url to send and also put those variables inside the body. the following example shows the error: ``` bug/echo/should return 200 reported errors: PARSING_ERROR Unable to parse - { "first_name": "<<first-name>>" ,"last-name": "<<lastname>>" } (ENV_EXPAND_LOOP) ``` a simplified version of the collection: ``` { "v": 1, "name": "bug", "folders": [ { "v": 1, "name": "echo", "folders": [], "requests": [ { "v": "1", "name": "should return 200", "endpoint": "https://echo.hoppscotch.io", "method": "POST", "headers": [], "params": [], "auth": { "authType": "none", "authActive": true }, "body": { "contentType": "application/json", "body": "{\n \"first_name\": \"<<first-name>>\" \n,\"last-name\": \"<<lastname>>\" \n}" }, "preRequestScript": "", "testScript": "" } ] }], "requests": [] } ``` env.json ``` { "name": "bug", "variables": [ { "key": "first-name", "value": "james" }, { "key": "lastname", "value": "bond" } ] } ```
Author
Owner

@jamesgeorge007 commented on GitHub (Dec 21, 2023):

Thanks for the sample exports. I reproduced the issue and have raised a fix.

This happened since the single environment export format only considered the first variable entry and the resolution step failed to find a match for other entries ending up in the ENV_EXPAND_LOOP state.

github.com/hoppscotch/hoppscotch@7db7b9b068/packages/hoppscotch-cli/src/options/test/env.ts (L39-L42)

github.com/hoppscotch/hoppscotch@7db7b9b068/packages/hoppscotch-data/src/environment/index.ts (L34-L55)

<!-- gh-comment-id:1866384932 --> @jamesgeorge007 commented on GitHub (Dec 21, 2023): Thanks for the sample exports. I reproduced the issue and have raised a [fix](https://github.com/hoppscotch/hoppscotch/pull/3687). This happened since the [single environment export format](https://docs.hoppscotch.io/documentation/clients/cli#_1-single-environment-entry-export-format) only considered the first variable entry and the resolution step failed to find a match for other entries ending up in the `ENV_EXPAND_LOOP` state. https://github.com/hoppscotch/hoppscotch/blob/7db7b9b0683424a594b85ac5265c4a5ff749586b/packages/hoppscotch-cli/src/options/test/env.ts#L39-L42 https://github.com/hoppscotch/hoppscotch/blob/7db7b9b0683424a594b85ac5265c4a5ff749586b/packages/hoppscotch-data/src/environment/index.ts#L34-L55
Author
Owner

@yvz5 commented on GitHub (Dec 21, 2023):

thanks for fixing it. when can I expect it to be released ?

<!-- gh-comment-id:1866395062 --> @yvz5 commented on GitHub (Dec 21, 2023): thanks for fixing it. when can I expect it to be released ?
Author
Owner

@jamesgeorge007 commented on GitHub (Dec 21, 2023):

This will be part of the v2023.12.1 release that will most probably happen tomorrow.

<!-- gh-comment-id:1866738407 --> @jamesgeorge007 commented on GitHub (Dec 21, 2023): This will be part of the `v2023.12.1` release that will most probably happen tomorrow.
Author
Owner

@jamesgeorge007 commented on GitHub (Dec 26, 2023):

This is fixed in CLI v0.5.1.

<!-- gh-comment-id:1869335370 --> @jamesgeorge007 commented on GitHub (Dec 26, 2023): This is fixed in [CLI v0.5.1](https://www.npmjs.com/package/@hoppscotch/cli/v/0.5.1).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#1266
No description provided.