Correct app-env equality check
Improve chat msg validation