Run:
db.test.aggregate([{
$group: {_id: null, median: {$percentile: {p: ["$$foo"], method: "approximate", input: "$a"}}}
}],
{let: {foo: 0.5}
})
Result: 'MongoServerError: BSON field '$percentile.p.0' is the wrong type 'string', expected types '[long, int, decimal, double]'
It looks like the idl validation kicks in before the expression is substituted from the "let" option.