Fix evaluation order for getting the key for checking duplicates
GCP-9147
Reviewer: Glenn