This commit also adds a test so that we can catch this problem hopefully sooner in the future. Closes gh-42006