Fix the undefined index 'id' in case of error