Bug 65108 - Passing a numeric variable to GraphQL HTTP Request logs an error and doesn't send any variables.
Summary: Passing a numeric variable to GraphQL HTTP Request logs an error and doesn't ...
Status: RESOLVED FIXED
Alias: None
Product: JMeter - Now in Github
Classification: Unclassified
Component: HTTP (show other bugs)
Version: 5.4
Hardware: PC All
: P2 normal (vote)
Target Milestone: JMETER 5.4.1
Assignee: JMeter issues mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-26 17:16 UTC by andy
Modified: 2022-05-24 19:08 UTC (History)
1 user (show)



Attachments
Simple example for testing (5.94 KB, application/xml)
2021-01-26 17:16 UTC, andy
Details

Note You need to log in before you can comment on or make changes to this bug.
Description andy 2021-01-26 17:16:43 UTC
Created attachment 37720 [details]
Simple example for testing

Using the GraphQL HTTP Request sampler with Variables set like this:

{
	"number": ${number}
}

(Note no " around the value)

Results in the following error:

2021-01-26 17:07:23,695 ERROR o.a.j.p.h.u.GraphQLRequestParamUtils: Ignoring the GraphQL query variables content due to the syntax error: Unrecognized token '$': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
 at [Source: (String)"{
	"number": ${number}
}
"; line: 2, column: 13]

And the POST Data is missing the variables:

POST data:
{"operationName":"Test","query":"query Test() {\n\t\n}"}

Adding quotes gives the expected behaviour:

POST data:
{"operationName":"Test","variables":{"number":"0"},"query":"query Test() {\n\t\n}"}

But the value is now passed as a string instead of a number, so is not the correct request.
Comment 1 Felix Schumacher 2021-01-26 17:27:20 UTC
Seems like the graphql sampler is parsing the JSON structure too early, i.e. when the variables are not set, yet.
Comment 2 Felix Schumacher 2021-03-12 21:24:41 UTC
https://github.com/apache/jmeter/pull/651
Comment 3 Felix Schumacher 2022-01-24 15:49:18 UTC
Should be fixed with https://github.com/apache/jmeter/pull/660

@Andy, could you test next nightly and report back?
Comment 4 andy 2022-01-24 21:57:35 UTC
Sorry, I've long since moved to a job where I'm not using jmeter anymore. I've passed it on to the team who are though.
Comment 5 Asaf Silman 2022-05-24 18:48:58 UTC
@Felix, I encounted the same issue which andy encountered, and can confirm that this PR fixes this issue. Tested on 5.5, latest commit: cbacd0893ed726a37ea4134598f2016936c01d91
Comment 6 The ASF infrastructure team 2022-09-24 20:38:21 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/5493