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

Can't access request data and resend the same request when random payload were used

Open onmywaytoheaven opened this issue 2 years ago • 19 comments

Describe the bug I can't access request data and resend the same request when I use random payload via custom filter.

For example. I created custom filter for random payload generation in order to assess proper backend validation. However, after I got failed iteration and opened failed request, I can't find the data that was submitted, all I see is variable with filter definition. image

If I tried to get Code Snippet of request, it will generate random payload everytime I click on it.

To Reproduce

  1. Use custom filter to generate random payload
async function fuzzFilter() {
    var _ = await tc.loadModule("underscore");
    var utf8 = await tc.loadModule("utf8");
    randomString = function (options) {
        var charCodes, charCodeLimit;
    
        options = options || {};
        charCodes = [];
        charCodeLimit = Math.pow(2, 16);
    
        _.times(_.random(options.maximumLength || 10), function () {
          charCodes.push(_.random(charCodeLimit));
        });
    
        return String.fromCharCode.apply(null, charCodes);
    };
    var res = randomString();
    return utf8.encode(res);
}
module.exports = [fuzzFilter];
  1. Run request with fuzzFilter for ex. in header

Expected behavior I can find exact request and resend it :)

Platform:

  • OS: Windows 10 22H2
  • vscode version: 1.74.1
  • extension version: 2.2.0

Your Team Size Using TC: Just me

onmywaytoheaven avatar Dec 23 '22 10:12 onmywaytoheaven

Thanks @onmywaytoheaven for reporting the bug,

just to clarify - the request you send is not saved in the sidebar?

rangav avatar Dec 23 '22 10:12 rangav

Can you see any errors in logs?

rangav avatar Dec 23 '22 10:12 rangav

I am running it from collection. In Thunder Client output I can see request headers for example, but it will be tough to find one when I run thousand iterations of the collection

onmywaytoheaven avatar Dec 23 '22 10:12 onmywaytoheaven

so you want to see request details send in logs for a request that is executed from Run Collection right?

you can re-run that single request see in logs from Run collection view image

rangav avatar Dec 23 '22 11:12 rangav

Moreover, I find that sometimes custom filter is not working. For example,

function thisFilterDoesNotWork() {
    var charCodes = [
        2,
        118,
        178,
        149
    ]
    var resultedString = String.fromCharCode.apply(null, charCodes);
    console.log(resultedString);
    return resultedString;
}

If you will try to run the filter above, for ex, in header, your header will remain as {{@ | thisFilterDoesNotWork}}. Thats because of charcode 2 in it. Deleting it will resolve a problem

onmywaytoheaven avatar Dec 23 '22 11:12 onmywaytoheaven

Thanks for reporting, will verify the issue.

rangav avatar Dec 23 '22 11:12 rangav

so you want to see request details send in logs for a request that is executed from Run Collection right?

you can re-run that single request see in logs from Run collection view image

yes, I want to resend exactly the same request

when I have failed iteration and click on the failed request image it will open it in a new tab image but I will not find exact request here, as you see, the value of Fuzz-Header is variable, not string

[added] and if I click on rerun, as you suggest, it will run filter again and the value of header will be not the same

onmywaytoheaven avatar Dec 23 '22 11:12 onmywaytoheaven

The header value will not be the same, as its a dynamic value.

rangav avatar Dec 23 '22 11:12 rangav

what solution would you like here?

rangav avatar Dec 23 '22 11:12 rangav

Yes, its dynamic, but when your test is failed, you need the same request to validate it, right? I guess its a bit counterintuitive that when I click on Run on the failed request, I get other request and other results. My think that request can be accessed on the right pane, with response... And for ex. when you click on Run on the failed test, request should be populated with actual data, that were sended.

onmywaytoheaven avatar Dec 23 '22 11:12 onmywaytoheaven

The purpose of dynamic value is to generate random value, and your tests needs to take this into account. When re-run a request it should still pass the all tests.

The solution you proposed will complicate things.

rangav avatar Dec 23 '22 11:12 rangav

Yes, it should. But if request fails, I can't even know why, I can't send it again.

onmywaytoheaven avatar Dec 23 '22 11:12 onmywaytoheaven

Well the Results tab will show why it failed and also you can re-send the request. both are possible as told the above.

Can you share screenshot your request and which tests failed?

rangav avatar Dec 23 '22 11:12 rangav

Its just a sandbox image

Test: responseCode == 400

onmywaytoheaven avatar Dec 23 '22 11:12 onmywaytoheaven

Well the Results tab will show why it failed and also you can re-send the request. both are possible as told the above.

Can you share screenshot your request and which tests failed?

Its possible, but Results tab and rerunning the request would not help me to get the same result

onmywaytoheaven avatar Dec 23 '22 11:12 onmywaytoheaven

from your screenshot, you know its failed because you 400 for responseCode, thats clear right?

Currently we dont save the dynamic values generated while sending request.

rangav avatar Dec 23 '22 11:12 rangav

from your screenshot, you know its failed because you 400 for responseCode, thats clear right?

Currently we dont save the dynamic values generated while sending request.

Sure, I know the outcomes, but I don't know what was the cause. It will be great if you ever implement such feature 😊 Thank you for Thunder Client!

onmywaytoheaven avatar Dec 23 '22 11:12 onmywaytoheaven

Sure will note your feedback, if we ever implement this feature will update here.

I look into the special characters issue your have with function - thisFilterDoesNotWork

rangav avatar Dec 23 '22 11:12 rangav

Moreover, I find that sometimes custom filter is not working. For example,

function thisFilterDoesNotWork() {
    var charCodes = [
        2,
        118,
        178,
        149
    ]
    var resultedString = String.fromCharCode.apply(null, charCodes);
    console.log(resultedString);
    return resultedString;
}

If you will try to run the filter above, for ex, in header, your header will remain as {{@ | thisFilterDoesNotWork}}. Thats because of charcode 2 in it. Deleting it will resolve a problem

You need to escape the resultedString for this to work. dont know how to escape this special char, try JSON.stringify

rangav avatar Dec 24 '22 11:12 rangav