From 31f1ba15ef01283b26ed45f797b5b719ddd67a01 Mon Sep 17 00:00:00 2001 From: Adam Moussa <166072409+amoussa1229@users.noreply.github.com> Date: Mon, 11 May 2026 13:57:30 -0400 Subject: [PATCH] Guard against phone entries missing value property --- lambda/index.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lambda/index.js b/lambda/index.js index 3d24bef..9b46017 100644 --- a/lambda/index.js +++ b/lambda/index.js @@ -146,11 +146,9 @@ function extractUserFields(googleUser) { let phone = ""; if (googleUser.phones && googleUser.phones.length > 0) { - const workPhone = googleUser.phones.find((p) => p.type === "work"); - const primaryPhone = googleUser.phones.find((p) => p.primary) || googleUser.phones[0]; - phone = workPhone - ? workPhone.value - : primaryPhone.value || ""; + const workPhone = googleUser.phones.find((p) => p.type === "work" && p.value); + const primaryPhone = googleUser.phones.find((p) => p.primary && p.value) || googleUser.phones.find((p) => p.value); + phone = (workPhone || primaryPhone || {}).value || ""; } return { email, jobTitle, phone };