Cannot read correctly variables used to repeat panels in MongoDB query

I have 2 dashboard variables, one for repeating rows, another one for repeating panels in a row. When I try to reference the variable used to repeat panels in MongoDB query, I face an error.
“cannot decode string into a primitive.D”.
When I checked Inspect->Network, query was not parsed and parsedQuery was empty. From the original query, I could find the variable was not converted into string. How can I fix it?