Throughout Npgsql we sometimes use Encoding.UTF8, and sometimes use the static instance UTF8Encoding on the BackendEncoding class. Neither of these throws an exception for invalid encoding.
Switch to an instance of UTF8Encoding which throws an exception when this happens.