From c765f22aef6599bcd87eadd88bef5749995a9f74 Mon Sep 17 00:00:00 2001 From: Alec Rippberger <127791530+alec-livefront@users.noreply.github.com> Date: Tue, 11 Mar 2025 10:56:12 -0500 Subject: [PATCH] fix(devices): [PM-18757] resolve invalid device data error for Android devices The device management screen was incorrectly evaluating the truthiness of DeviceView.type enum, causing "Invalid device data" errors when an Android device (type = 0) was present. Changed the check to explicitly verify for undefined values instead of truthy checks. - Updated type checking to use explicit undefined checks - Added translations for error messages - Improved error handling with specific messages for missing data Fixes PM-18757 --- .../security/device-management.component.ts | 16 ++++++++++++++-- apps/web/src/locales/en/messages.json | 9 +++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/apps/web/src/app/auth/settings/security/device-management.component.ts b/apps/web/src/app/auth/settings/security/device-management.component.ts index 97107cc0c0b..0f31b8d4639 100644 --- a/apps/web/src/app/auth/settings/security/device-management.component.ts +++ b/apps/web/src/app/auth/settings/security/device-management.component.ts @@ -180,8 +180,20 @@ export class DeviceManagementComponent { private updateDeviceTable(devices: Array): void { this.dataSource.data = devices .map((device: DeviceView): DeviceTableData | null => { - if (!device.id || !device.type || !device.creationDate) { - this.validationService.showError(new Error("Invalid device data")); + if (device.id == undefined) { + this.validationService.showError(new Error(this.i18nService.t("deviceIdMissing"))); + return null; + } + + if (device.type == undefined) { + this.validationService.showError(new Error(this.i18nService.t("deviceTypeMissing"))); + return null; + } + + if (device.creationDate == undefined) { + this.validationService.showError( + new Error(this.i18nService.t("deviceCreationDateMissing")), + ); return null; } diff --git a/apps/web/src/locales/en/messages.json b/apps/web/src/locales/en/messages.json index 0a5ede50462..68900b2ed74 100644 --- a/apps/web/src/locales/en/messages.json +++ b/apps/web/src/locales/en/messages.json @@ -9412,6 +9412,15 @@ "deviceManagementDesc": { "message": "Configure device management for Bitwarden using the implementation guide for your platform." }, + "deviceIdMissing": { + "message": "Device ID is missing" + }, + "deviceTypeMissing": { + "message": "Device type is missing" + }, + "deviceCreationDateMissing": { + "message": "Device creation date is missing" + }, "desktopRequired": { "message": "Desktop required" },