Try this in the Atlas aggregation tool, or via Compass - does the error occur there?