From 0785224219211bf30d3fb0effee6f813e1c4f0db Mon Sep 17 00:00:00 2001 From: Nicolas Burtey Date: Wed, 6 Dec 2023 19:23:16 -0600 Subject: [PATCH] chore: do not return error on InvalidMobileCountryCodeForPhoneMetadataError --- core/api/src/domain/users/index.types.d.ts | 4 ++-- core/api/src/domain/users/phone-metadata-validator.ts | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/core/api/src/domain/users/index.types.d.ts b/core/api/src/domain/users/index.types.d.ts index 660bf6ac419..1a2ec96ca52 100644 --- a/core/api/src/domain/users/index.types.d.ts +++ b/core/api/src/domain/users/index.types.d.ts @@ -22,8 +22,8 @@ type ChannelType = type PhoneMetadata = { // from twilio carrier: { - error_code: string // check this is the right syntax - mobile_country_code: string + error_code: string | null + mobile_country_code: string | null mobile_network_code: string | null name: string | null type: CarrierType | null diff --git a/core/api/src/domain/users/phone-metadata-validator.ts b/core/api/src/domain/users/phone-metadata-validator.ts index 602e49faf6b..e1603ec7cdf 100644 --- a/core/api/src/domain/users/phone-metadata-validator.ts +++ b/core/api/src/domain/users/phone-metadata-validator.ts @@ -1,3 +1,4 @@ +import { recordExceptionInCurrentSpan } from "@/services/tracing" import { InvalidCarrierForPhoneMetadataError, InvalidCarrierTypeForPhoneMetadataError, @@ -7,6 +8,7 @@ import { } from "./errors" import { CarrierType } from "@/domain/phone-provider" +import { ErrorLevel } from "../shared" const checkedToCarrierType = ( rawCarrierType: string | undefined | null, @@ -47,7 +49,10 @@ export const PhoneMetadataValidator = (): PhoneMetadataValidator => { } if (typeof mobile_country_code !== "string") { - return new InvalidMobileCountryCodeForPhoneMetadataError(mobile_country_code) + recordExceptionInCurrentSpan({ + error: new InvalidMobileCountryCodeForPhoneMetadataError(mobile_country_code), + level: ErrorLevel.Critical, + }) } if (typeof countryCode !== "string") {