# scala.collection.immutable.List out of VALUE_STRING when query with List[String] for multi-valued param
###### tags: `Scala`
- ReactiveMongo Version: 0.13.0
- MongoDB version 0.2.4(embedmongo)
- Operating System: MacOS 12.3 arm64 M1 chip
- JDK corretto-1.8 (java version: 1.8_362)
- Library Dependencies
Finatra/Finagle/Twitter Server
I have an API with a multi-valued parameter in single same key, just like: /api/designedservice?key1=value1&key1=value2
And I set a case class as the request parameter when query data by from DB, like:
```scala=
case class GetValueFromDBReq(@QueryParam singleValue1: Option[String] = None,
@QueryParam singleValue2: Option[String] = None,
@QueryParam multiValue: Option[List[String]] = None)
```
(the default value is set as for legacy design)
following is the DBqueryService I did:
```scala=
class DBGetService @Inject()(@Coll coll: ScalaFuture[Maybe[BSONCollection]])
extends Service[GetValueFromDBReq, Maybe[List[TargetCollection]]]{
override def apply(req: GetValueFromDBReq): Future[Maybe[List[TargetCollection]] = {
val con1 = BSONDocument("singleValue" => req.singleValue1)
val con2 = BSONDocument("singleValue" => req.singleValue2)
val con3 = req.multiValue match {
case Some(s) => BSONDocument("multiValue" => BSONDocument("$in" -> s))
case None => BSONDocument()
}
...
coll.flatMap {
case OK(c) => {
(for {
r <- c.find(con1 ++ con2 ++ con3)
.cursor[TargetCollection]()
.collect[List]
} yield {
r
}).toTwitterFuture
.map(a => OK(a))
.handle {
....
// error handling
}
}
case KO(e) => {
...
// error handling
}
}
}
}
```
The expected result is to return 200 with a List of the TargetCollection.
Currently it works when querying by singleValue1 and singleValue2 (or both), but when I used multiValue as the condition, it response 400 with following log:
```bash=
[info] Received Response:
[info] HTTP/1.1 400 Bad Request
[info] Date: Tue, 02 May 2023 03:15:12 GMT
[info] Server: Finatra
[info] Content-Length: 158
[info] Content-Type: application/json; charset=utf-8
[info]
[info] {"errors":["multiValue: Cannot deserialize instance of `scala.collection.immutable.List` out of VALUE_STRING token\n at [Source: UNKNOWN; line: -1, column: -1]"]}
```
I've tried the following commands also:
```scala=
val con3 = BSONDocument("multiValue" => req.multiValue)
val con3 = req.multiValue match {
case Some(s) => s.map(r => BSONDocument("multiValue" -> r)).reduce(_ ++ _)
case None => BSONDocument()
}
val con3 = req.multiValue match {
case Some(s) => BSONDocument("multiValue" -> BSONDocument("$in" -> s.toArray))
case None => BSONDocument()
}
val con3 = req.multiValue match {
case Some(s) => BSONDocument("multiValue" -> BSONDocument("$in" -> BSONArray(s)))
case None => BSONDocument()
}
val con3 = req.multiValue.map(x => BSONDocument("multiValue" -> BSONDocument("$in" -> x))) match{
case Some(s) => s
case None => BSONDocument()
}
```
And got the same error log.
Hope to know if there is anybody met the same problem before, thanks.