Fix bug with incorrect error on missing key