PebbleString - Failed to build request: s.MatchError: null

Hitting an issue and don’t understand the cause. I’m using a PebbleString body and am getting a MatchError on generating the request. Anybody have any ideas?

12:07:34.201 [gatling-1-2] DEBUG i.g.commons.validation.package$ - Failed to build request: s.MatchError: null
scala.MatchError: null
at io.gatling.core.body.Pebble$.anyRefToJava(Pebble.scala:72)
at io.gatling.core.body.Pebble$.$anonfun$immutableMapToJava$1(Pebble.scala:70)
at scala.collection.MapView$MapValues.$anonfun$iterator$1(MapView.scala:119)
at scala.collection.Iterator$$anon$9.next(Iterator.scala:575)
at scala.collection.Iterator$ConcatIterator.next(Iterator.scala:1182)
at scala.collection.mutable.Growable.addAll(Growable.scala:62)
at scala.collection.mutable.Growable.addAll$(Growable.scala:57)
at scala.collection.immutable.MapBuilderImpl.addAll(Map.scala:692)
at scala.collection.immutable.Map$.from(Map.scala:643)
at scala.collection.immutable.Map$.from(Map.scala:173)
at scala.collection.MapOps.concat(Map.scala:298)
at scala.collection.MapOps.concat$(Map.scala:298)
at scala.collection.immutable.Map$EmptyMap$.concat(Map.scala:236)
at scala.collection.immutable.Map$EmptyMap$.concat(Map.scala:221)
at scala.collection.MapOps.$plus$plus(Map.scala:306)
at scala.collection.MapOps.$plus$plus$(Map.scala:306)
at scala.collection.AbstractMap.$plus$plus(Map.scala:372)
at io.gatling.core.body.Pebble$.immutableMapToJava(Pebble.scala:70)
at io.gatling.core.body.Pebble$.anyRefToJava(Pebble.scala:78)
at io.gatling.core.body.Pebble$.$anonfun$immutableSeqToJava$1(Pebble.scala:58)
at scala.collection.immutable.ArraySeq.$anonfun$map$1(ArraySeq.scala:71)
at scala.collection.immutable.ArraySeq.$anonfun$map$1$adapted(ArraySeq.scala:71)
at scala.collection.immutable.ArraySeq$.tabulate(ArraySeq.scala:286)
at scala.collection.immutable.ArraySeq$.tabulate(ArraySeq.scala:265)
at scala.collection.ClassTagIterableFactory$AnyIterableDelegate.tabulate(Factory.scala:679)
at scala.collection.immutable.ArraySeq.map(ArraySeq.scala:71)
at scala.collection.immutable.ArraySeq.map(ArraySeq.scala:35)
at io.gatling.core.body.Pebble$.immutableSeqToJava(Pebble.scala:58)
at io.gatling.core.body.Pebble$.anyRefToJava(Pebble.scala:74)
at io.gatling.core.body.Pebble$.$anonfun$immutableMapToJava$1(Pebble.scala:70)
at scala.collection.MapView$MapValues.$anonfun$iterator$1(MapView.scala:119)
at scala.collection.Iterator$$anon$9.next(Iterator.scala:575)
at scala.collection.Iterator$ConcatIterator.next(Iterator.scala:1182)
at scala.collection.mutable.Growable.addAll(Growable.scala:62)
at scala.collection.mutable.Growable.addAll$(Growable.scala:57)
at scala.collection.immutable.MapBuilderImpl.addAll(Map.scala:692)
at scala.collection.immutable.Map$.from(Map.scala:643)
at scala.collection.immutable.Map$.from(Map.scala:173)
at scala.collection.MapOps.concat(Map.scala:298)
at scala.collection.MapOps.concat$(Map.scala:298)
at scala.collection.immutable.Map$EmptyMap$.concat(Map.scala:236)
at scala.collection.immutable.Map$EmptyMap$.concat(Map.scala:221)
at scala.collection.MapOps.$plus$plus(Map.scala:306)
at scala.collection.MapOps.$plus$plus$(Map.scala:306)
at scala.collection.AbstractMap.$plus$plus(Map.scala:372)
at io.gatling.core.body.Pebble$.immutableMapToJava(Pebble.scala:70)
at io.gatling.core.body.Pebble$.anyRefToJava(Pebble.scala:78)
at io.gatling.core.body.Pebble$.$anonfun$sessionAttributesToJava$2(Pebble.scala:85)
at scala.collection.IterableOnceOps.foreach(IterableOnce.scala:563)
at scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:561)
at scala.collection.AbstractIterable.foreach(Iterable.scala:919)
at scala.collection.IterableOps$WithFilter.foreach(Iterable.scala:889)
at io.gatling.core.body.Pebble$.sessionAttributesToJava(Pebble.scala:84)
at io.gatling.core.body.Pebble$.evaluateTemplate(Pebble.scala:115)
at io.gatling.core.body.PebbleStringBody$.$anonfun$apply$10(Body.scala:108)
at io.gatling.commons.validation.Success.flatMap(Validation.scala:38)
at io.gatling.core.body.PebbleStringBody$.$anonfun$apply$9(Body.scala:108)
at io.gatling.http.request.builder.HttpRequestExpressionBuilder.setBody(HttpRequestExpressionBuilder.scala:72)
at io.gatling.http.request.builder.HttpRequestExpressionBuilder.$anonfun$configureBody$3(HttpRequestExpressionBuilder.scala:90)
at io.gatling.http.request.builder.HttpRequestExpressionBuilder.$anonfun$configureRequestBuilderForProtocol$2(HttpRequestExpressionBuilder.scala:125)
at io.gatling.commons.validation.Success.flatMap(Validation.scala:38)
at io.gatling.http.request.builder.RequestExpressionBuilder.configureRequestBuilder(RequestExpressionBuilder.scala:229)
at io.gatling.http.request.builder.RequestExpressionBuilder.$anonfun$build$4(RequestExpressionBuilder.scala:239)
at io.gatling.commons.validation.Success.flatMap(Validation.scala:38)
at io.gatling.http.request.builder.RequestExpressionBuilder.$anonfun$build$3(RequestExpressionBuilder.scala:237)
at io.gatling.commons.validation.Success.flatMap(Validation.scala:38)
at io.gatling.http.request.builder.RequestExpressionBuilder.$anonfun$build$2(RequestExpressionBuilder.scala:236)
at io.gatling.commons.validation.package$.safely(package.scala:36)
at io.gatling.http.request.builder.RequestExpressionBuilder.$anonfun$build$1(RequestExpressionBuilder.scala:236)
at io.gatling.http.request.builder.HttpRequestExpressionBuilder.$anonfun$build$1(HttpRequestExpressionBuilder.scala:140)
at io.gatling.http.request.HttpRequestDef.build(HttpRequest.scala:49)
at io.gatling.http.action.HttpRequestAction.sendRequest(HttpRequestAction.scala:49)
at io.gatling.core.action.RequestAction.$anonfun$execute$1(Action.scala:119)
at io.gatling.commons.validation.Success.flatMap(Validation.scala:38)
at io.gatling.core.action.RequestAction.execute(Action.scala:116)
at io.gatling.core.action.RequestAction.execute$(Action.scala:115)
at io.gatling.http.action.HttpRequestAction.execute(HttpRequestAction.scala:32)
at io.gatling.core.action.Action.$bang(Action.scala:41)
at io.gatling.core.action.Action.$bang$(Action.scala:38)
at io.gatling.http.action.HttpRequestAction.io$gatling$core$action$ChainableAction$$super$$bang(HttpRequestAction.scala:32)
at io.gatling.core.action.ChainableAction.$bang(Action.scala:70)
at io.gatling.core.action.ChainableAction.$bang$(Action.scala:68)
at io.gatling.http.action.HttpRequestAction.io$gatling$core$action$ExitableAction$$super$$bang(HttpRequestAction.scala:32)
at io.gatling.core.action.ExitableAction.$bang(Action.scala:106)
at io.gatling.core.action.ExitableAction.$bang$(Action.scala:103)
at io.gatling.http.action.HttpRequestAction.$bang(HttpRequestAction.scala:32)
at io.gatling.core.action.SessionHook.$anonfun$execute$1(SessionHook.scala:32)
at io.gatling.core.action.SessionHook.$anonfun$execute$1$adapted(SessionHook.scala:32)
at io.gatling.commons.validation.Success.map(Validation.scala:37)
at io.gatling.core.action.SessionHook.execute(SessionHook.scala:32)
at io.gatling.core.action.Action.$bang(Action.scala:41)
at io.gatling.core.action.Action.$bang$(Action.scala:38)
at io.gatling.core.action.SessionHook.io$gatling$core$action$ChainableAction$$super$$bang(SessionHook.scala:23)
at io.gatling.core.action.ChainableAction.$bang(Action.scala:70)
at io.gatling.core.action.ChainableAction.$bang$(Action.scala:68)
at io.gatling.core.action.builder.SessionHookBuilder$$anon$1.io$gatling$core$action$ExitableAction$$super$$bang(SessionHookBuilder.scala:29)
at io.gatling.core.action.ExitableAction.$bang(Action.scala:106)
at io.gatling.core.action.ExitableAction.$bang$(Action.scala:103)
at io.gatling.core.action.builder.SessionHookBuilder$$anon$1.$bang(SessionHookBuilder.scala:29)
at io.gatling.core.action.Switch.$anonfun$execute$1(Switch.scala:26)
at io.gatling.core.action.Switch.$anonfun$execute$1$adapted(Switch.scala:26)
at io.gatling.commons.validation.Success.map(Validation.scala:37)
at io.gatling.core.action.Switch.execute(Switch.scala:26)
at io.gatling.core.action.Action.$bang(Action.scala:41)
at io.gatling.core.action.Action.$bang$(Action.scala:38)
at io.gatling.core.action.Switch.io$gatling$core$action$ChainableAction$$super$$bang(Switch.scala:23)
at io.gatling.core.action.ChainableAction.$bang(Action.scala:70)
at io.gatling.core.action.ChainableAction.$bang$(Action.scala:68)
at io.gatling.core.action.Switch.io$gatling$core$action$ExitableAction$$super$$bang(Switch.scala:23)
at io.gatling.core.action.ExitableAction.$bang(Action.scala:106)
at io.gatling.core.action.ExitableAction.$bang$(Action.scala:103)
at io.gatling.core.action.Switch.$bang(Switch.scala:23)
at io.gatling.core.action.InnerLoop.$anonfun$execute$1(Loop.scala:90)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:497)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:834)
12:07:34.202 [gatling-1-2] ERROR i.g.http.action.HttpRequestAction - ‘httpRequest-112’ failed to execute: Failed to build request: s.MatchError: null

I should add that I don’t think it has anything to do with the actual template as I can replace it with a static string and still face the error. It is not happening on every call. I’m confused about what is null at that point within the Gatling Pebble code

Hi,

How can we reproduce your issue on our side?

OK, got it. Somehow, you’re storing a null attribute in the Session. Is it expected?

Thanks for the direction. I think I have a workaround/fix. We were storing some maps on the session for processing in some later logic based on other state. These maps were constructed from json responses from an API. Removing some of these maps from the session when they were no longer needed did avoid this error.

Is this an issue in Gatling? Or is this some kind of bad practive to push a map onto the session?

An issue with Gatling: https://github.com/gatling/gatling/issues/4101

That being said, cleaning up unused data stored in Sessions is a good practice to avoid OOME.

The only error message that I got was this: Failed to build request: Failed to build request: s.MatchError…

For those that stumble on this problem. For me it was that sometimes the feeder that I was using contained null values. I was using a query as a basis for the feeder, but some records contained null values. Thanks to this post I got the idea to use a PebbleStringBody instead of a PebbleFileBody, which didn’t fix my problem. Afterwards I changed all the {{}} paramters in my file. This fixed my problem. So I checked my feeders and found the problem in my queries.

I hope that this post helps somebody. A more explicit message that the Feeder contained a null value would have been a great help.

Failed to build request: Failed to build request: s.MatchError…

Any chance you had a full stracktrace in the logs?

Also, which version of Gatling did you use? Did you verify you also experience this issue with 3.6.1,

After fixing the problem it was hard to recreate. I did manage to get empty feeder error, but my more obscure error that the feeder contains a null value only generates the error line as said above. I added two lines from the console after recreateing the prblem below.

I was running Gatling 3.6.0 and upgraded to 3.6.1. When I upgraded to Gatling 3.6.1 the problem seemed to disapear completely.

10:45:42.913 [ERROR] i.g.h.a.HttpRequestAction - ‘httpRequest-2’ failed to execute: Failed to build request: s.MatchError: null
10:45:42.914 [ERROR] i.g.h.a.HttpRequestAction - ‘httpRequest-2’ failed to execute: Failed to build request: s.MatchError: null

So indeed, it’s a known issue that was fixed in 3.6.1: https://github.com/gatling/gatling/issues/4101

Of the importance to upgrade :wink: