BHV-18024: 

Cherry-picking from master into 2.5-upkeep.