Backport of #8325 to release/dsh-0.2.2. (cherry picked from commit 907c47c8f251cae6ce844cf8c7145bbfd5dbe176)