Add null check when retrieving key ids from contacts api