From 7940128bf963a0eb7de1da84d33a180a94884cd1 Mon Sep 17 00:00:00 2001 From: Crisrael Lucero Date: Tue, 27 May 2025 12:07:48 -0700 Subject: [PATCH] Assign empty string to `bluetooth_mac_address` instead of invalid argument PiperOrigin-RevId: 763894090 --- .../implementation/ble_advertisement.cc | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/connections/implementation/ble_advertisement.cc b/connections/implementation/ble_advertisement.cc index 9776a797..4e2d93ef 100644 --- a/connections/implementation/ble_advertisement.cc +++ b/connections/implementation/ble_advertisement.cc @@ -206,19 +206,19 @@ absl::StatusOr BleAdvertisement::CreateBleAdvertisement( absl::StatusOr bluetooth_mac_address_bytes_uint64 = bluetooth_mac_address_bytes->Read6BytesAsUint64(); - if (!bluetooth_mac_address_bytes_uint64.ok()) { - return absl::InvalidArgumentError( - "Cannot deserialize BleAdvertisement: bluetooth_mac_address."); - } - MacAddress mac_address; - if (!MacAddress::FromUint64(bluetooth_mac_address_bytes_uint64.value(), - mac_address) || - !mac_address.IsSet()) { - return absl::InvalidArgumentError( - "Cannot convert BleAdvertisement: bluetooth_mac_address."); + // TODO(b/420331699): Returning an empty string for the MAC address when + // there's an invalid ByteArray is problematic, determine where an invalid + // ByteArray is being passed in upstream so we can modify this to not use + // an empty string. + if (bluetooth_mac_address_bytes_uint64.ok() && + MacAddress::FromUint64(bluetooth_mac_address_bytes_uint64.value(), + mac_address) && + mac_address.IsSet()) { + bluetooth_mac_address = mac_address.ToString(); + } else { + bluetooth_mac_address = ""; } - bluetooth_mac_address = mac_address.ToString(); } // The next 1 byte is supposed to be the length of the uwb_address. If the