0.39.x: Backport 1448 and 1454

This cherry-picks the commits from !1448 (merged) and !1454 (merged) to fix a crash to 0.39

Merge request reports

Loading