Fix response flatten infinite recursion

Fixes #13921