Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use comma separated parameter value in DataunctionHandler #337

Closed
gourighode opened this issue Apr 3, 2024 Discussed in #336 · 3 comments
Closed

Unable to use comma separated parameter value in DataunctionHandler #337

gourighode opened this issue Apr 3, 2024 Discussed in #336 · 3 comments

Comments

@gourighode
Copy link

gourighode commented Apr 3, 2024

Discussed in #336

Originally posted by gourighode April 3, 2024
We are using DataFunctionHandler concept to prepare request body with dynamic values for some keys.

In some of the scenarios value of specific key is comma separated

Example of Sample handler

handler.addDataFuncHandler(’SamplePayLoad', (ctx) => {
const source = ctx.args[0];
console.log("*********************",source)
const basePayload = {
source: ctx.args[4],
};
return basePayload;
});

Value being passed for source while calling data function handler in actual test is A,B this combined value is needed for source however currently it is splitting it between 2 different parameters and hence value for source is appearing as only A

Can someone help in clarifying if is there any way to tackle this issue?

@leelaprasadv
Copy link
Member

@gourighode DataFunctions processor by default uses "," as a delimiter. To my knowledge, it's not that common to have "," in a key.

With the above limitation, you will have to choose a different delimiter (ex: |, _, etc) in the source key while sending parameters to the Data Function and replace it in the Data function handler as a workaround.

const source = ctx.args[0].replace("|",",");

And data function invocation $F{SamplePayload:A|B,....rest of params}

@gourighode
Copy link
Author

@leelaprasadv Even when we are passing array of values from DataFunctionHandler call it's splitting array values with "," delimiter. As long as I understand array with comma separated values will be common scenario to be passed from datafunction handler

e,g.

const buildArray = [buildId1, buildId2];

.withBody($F{SamplePayload:${buildName},${buildArray},${projectId}})

@leelaprasadv
Copy link
Member

Yes, as mentioned earlier - due to the limitation we have currently even arrays will not work. You will have to temporarily convert them into a delimited string (other than ",") before passing it to the function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants