thunder-client-support icon indicating copy to clipboard operation
thunder-client-support copied to clipboard

Tests filter parameter value truncated.

Open programatix opened this issue 2 years ago • 1 comments

Describe the bug The following statement in Test, on the left side will cause the parameter value to be truncated.

image

The script is as follow,

function validateObject(probe, reference) {
    console.log(probe);
    console.log(reference);
}

The value for probe is correct. However, the value for reference is truncated from, "hello there", said Peter to "hello there

The cause of the issue is due to the double quotes, followed by a comma. There can be spaces between the double quote and the comma and the truncation will occur.

The following example will also cause truncation, "\"hello there\" , said Peter" will produce "hello there

Inserting any characters in between the double quote and the comma will result in no truncation. For example, "\"hello there\" . , said Peter" will produce "hello there" . , said Peter

To Reproduce

  • Create a new request.
  • In the Tests, add the string json.data | validateObject("\"hello there\", said Peter")
  • Create a custom filter.
    function validateObject(probe, reference) {
      console.log(probe);
      console.log(reference);
    }
    
  • Run the request and see the output.

Expected behavior The parameter reference should contain the full string "hello there", said Peter.

In my actual project, the actual data is a variable which contain a json string in an Environment,

      {
        "name": "test",
        "value": "{\"name\":\"My name\",\"description\":\"A short description\",\"data\":{\"type\":\"DataType\"}}"
      }

and I'm trying to perform custom object validation as such in Tests, json.data | validateObject({{test}}) image

In the filter, I would parse it into a json object and perform some validation. The issue is, the value is truncated causing the actual input to be lost.

Platform:

  • OS: Windows 10
  • vscode version: 1.78.1
  • extension version: 2.6.2

Your Team Size Using TC: 2

programatix avatar May 10 '23 12:05 programatix

Thanks @programatix for reporting the bug, Currently additional quotes are not allowed

rangav avatar May 13 '23 17:05 rangav

Closing this issue, Please use scripting for this use-case.

rangav avatar May 07 '24 18:05 rangav