Prevent calls to erase with invalid keys.