# Type mismatch: found string, io.gatling.core.session.Session required

**URL:** <https://community.gatling.io/t/type-mismatch-found-string-io-gatling-core-session-session-required/5565>\
**Category:** Gatling (Open-Source)\
**Created:** [March 29, 2020, 4:12pm UTC](https://community.gatling.io/t/type-mismatch-found-string-io-gatling-core-session-session-required/5565 "2020-03-29T16:12:11Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steve\_Shulman-Laniel](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@Steve\_Shulman-Laniel](https://community.gatling.io/u/Steve_Shulman-Laniel)\
**Post date:** [March 29, 2020, 4:12pm UTC](https://community.gatling.io/t/type-mismatch-found-string-io-gatling-core-session-session-required/5565/1 "2020-03-29T16:12:11Z")

</div>

Hi folks,

I know this is a topic that comes up with some regularity, having Googled for it a bunch, but:

[Error] /path/to/whatever.scala:62: type mismatch;  
found : String(“oauth\_client\_id”)  
required: io.gatling.core.session.Session

Everywhere I’ve seen this mentioned, the suggestion is to “import io.gatling.core.Predef.\_”. I’ve already done that, yet I’m still getting the error.

It’s also showing up in a weird place: line 62, which is where the error above shows up, is here:

class FooSimulation extends Simulation {  
var util = new SecretsManagerUtil  
val secretMap = util.getOAuthClientAndSecret()  
val clientId = secretMap(“oauth\_client\_id”)  
val clientSecret = secretMap(“oauth\_client\_secret”)

Later on, those variables are to be used like so:

.formParam(“client\_id”, “${clientId}”) |~  
.formParam(“client\_secret”, “${clientSecret}”)

That is, at the point when I retrieve the clientId and clientSecret from the secretMap, they’ve not yet been taken for any purpose in Gatling, so I’m surprised that they need to be a particular Gatling type rather than ordinary String objects.

I’m new to Scala, so I’m sure this is some Scala- or Gatling-DSL-specific thing that is blindingly obvious to more-experienced Scala developers.

Can someone clue me in on what obvious thing I’m missing here?

Many thanks,  
Steve

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [March 29, 2020, 7:04pm UTC](https://community.gatling.io/t/type-mismatch-found-string-io-gatling-core-session-session-required/5565/2 "2020-03-29T19:04:20Z")

</div>

It looks like your secretMap custom method expects a Session but you’re passing a String (“oauth\_client\_id”).

---

<div class="post-metadata">

**Author:** ![Steve\_Shulman-Laniel](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@Steve\_Shulman-Laniel](https://community.gatling.io/u/Steve_Shulman-Laniel)\
**Post date:** [March 30, 2020, 12:03am UTC](https://community.gatling.io/t/type-mismatch-found-string-io-gatling-core-session-session-required/5565/3 "2020-03-30T00:03:45Z")

</div>

Hi Stéphane,

Yes, exactly. I don’t know why it expects a Session, though. Is it possible that Gatling has overridden the .get() or .getOrElse() methods somewhere?

Rewritten a little for the sake of clarity, the part of the code that secretMap shows up in is this:

class DiningOptionsSimulation extends Simulation {  
val util = new SecretsManagerUtil  
val oauth\_map = JSON.parseFull(util.getOAuthClientAndSecret())  
val clientId = oauth\_map.get(“oauth\_client\_id”)  
val clientSecret = oauth\_map.get(“oauth\_client\_secret”)

getOAuthClientAndSecret() is just a little convenience method to talk to AWS Secrets Manager:

def getOAuthClientAndSecret() : String = {  
val client = SecretsManagerClient.create()

val req = GetSecretValueRequest.builder()  
.secretId(secretName)  
.build()

val res = client.getSecretValue(req)  
return res.secretString()  
}  
}

So oauth\_map is the result of a JSON parse from the standard library; and it’s parsing the output of getOAuthClientAndSecret(), which returns a string.

I can’t figure out how a Session would slip in here. What am I missing?

Cheers,  
Steve

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [March 30, 2020, 10:00am UTC](https://community.gatling.io/t/type-mismatch-found-string-io-gatling-core-session-session-required/5565/4 "2020-03-30T10:00:30Z")

</div>

Impossible to tell without you provide the full sample.

---

<div class="post-metadata">

**Author:** ![Steve\_Shulman-Laniel](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@Steve\_Shulman-Laniel](https://community.gatling.io/u/Steve_Shulman-Laniel)\
**Post date:** [March 30, 2020, 12:02pm UTC](https://community.gatling.io/t/type-mismatch-found-string-io-gatling-core-session-session-required/5565/5 "2020-03-30T12:02:42Z")

</div>

Hi Stéphane,

Sure. See attached.

Thanks very much,  
Steve

[gatling\_sample.scala](https://community.gatling.io/uploads/short-url/59SIPl0RITF9vDiRLTA9wRoAbb3.scala) (2.28 KB)

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [March 30, 2020, 12:40pm UTC](https://community.gatling.io/t/type-mismatch-found-string-io-gatling-core-session-session-required/5565/6 "2020-03-30T12:40:29Z")

</div>

So, your code is wrong and your issue has nothing to do with Gatling.

JSON.parseFull returns a Option[Any] (your JSON can be empty, an array or an object).

oauth\_map is a Option[Any], and Option has a parameterless get method that returns the value if defined or throw an Exception otherwise. It doesn’t take a String and oauth\_map.get(“oauth\_client\_id”) doesn’t compile.

You have to fix your JSON parsing.

---

<div class="post-metadata">

**Author:** ![Steve\_Shulman-Laniel](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@Steve\_Shulman-Laniel](https://community.gatling.io/u/Steve_Shulman-Laniel)\
**Post date:** [March 30, 2020, 1:34pm UTC](https://community.gatling.io/t/type-mismatch-found-string-io-gatling-core-session-session-required/5565/7 "2020-03-30T13:34:30Z")

</div>

Thanks, Stéphane; that got me over the hump.

The error did seem to suggest something involving Gatling Session objects. Is that a sort of error that people familiar with Scala would have immediately understood to mean something else?

I appreciate your helping a newbie.

Many thanks,  
Steve

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [March 30, 2020, 1:38pm UTC](https://community.gatling.io/t/type-mismatch-found-string-io-gatling-core-session-session-required/5565/8 "2020-03-30T13:38:32Z")

</div>

You’re welcome.

Then, if you’re not familiar with Scala, you can probably code this in Java and then call it from Scala.
