Fix a bug when upserting a new repo