fix potential stack overflow with non-json responses