generate - KeyError handling