Repository: electron/electron (language: cpp)

Issue:
`shell.readShortcutLink` crashes when parsing Slack shortcut
### Preflight Checklist

- [x] I have read the [Contributing Guidelines](https://github.com/electron/electron/blob/main/CONTRIBUTING.md) for this project.
- [x] I agree to follow the [Code of Conduct](https://github.com/electron/electron/blob/main/CODE_OF_CONDUCT.md) that this project adheres to.
- [x] I have searched the [issue tracker](https://www.github.com/electron/electron/issues) for a bug report that matches the one I want to file, without success.

### Electron Version

33.3.1

### What operating system(s) are you using?

Windows

### Operating System Version

Windows 11 version 26100

### What arch are you using?

x64

### Last Known Working Electron version

_No response_

### Expected Behavior

Shortcut should be parsed/read correctly, and we should be able to handle the error if this fails.

### Actual Behavior

An exception is thrown:

```
[1212:0109/171356.871:ERROR:crashpad_client_win.cc(868)] not connected
```

### Testcase Gist URL

https://gist.github.com/dlon/f580673b27ba00d1bedfa25d2f2208c1

### Additional Information

This seems related to https://github.com/electron/electron/issues/44752, but it affects other shortcuts.

Here is a partial backtrace:
```
00 00000072`1e5fc3a0 00007ff7`f38192e9     electron!base::win::ResolveShortcutProperties+0xaaa [C:\projects\src\base\win\shortcut.cc @ 345] 
01 00000072`1e5fc6e0 00007ff7`f36ecd16     electron!`anonymous namespace'::ReadShortcutLink+0xd9 [C:\projects\src\electron\shell\common\api\electron_api_shell.cc @ 154] 
```

I've reproduced the above on v33.3.1, as well as the latest beta.


Discussion / hints:
I've found an issue and fix. I'll try to provide a patch when I have time.

Fix patch:
diff --git a/patches/chromium/.patches b/patches/chromium/.patches
index f6471212332bf..671a98a5b49d5 100644
--- a/patches/chromium/.patches
+++ b/patches/chromium/.patches
@@ -139,3 +139,4 @@ build_disable_thin_lto_mac.patch
 build_add_public_config_simdutf_config.patch
 revert_code_health_clean_up_stale_macwebcontentsocclusion.patch
 build_remove_vr_directx_helpers_dependency.patch
+ignore_parse_errors_for_pkey_appusermodel_toastactivatorclsid.patch
diff --git a/patches/chromium/ignore_parse_errors_for_pkey_appusermodel_toastactivatorclsid.patch b/patches/chromium/ignore_parse_errors_for_pkey_appusermodel_toastactivatorclsid.patch
new file mode 100644
index 0000000000000..6f97dd9b9ce80
--- /dev/null
+++ b/patches/chromium/ignore_parse_errors_for_pkey_appusermodel_toastactivatorclsid.patch
@@ -0,0 +1,40 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?David=20L=C3=B6nnhager?= <dv.lnh.d@gmail.com>
+Date: Fri, 17 Jan 2025 14:30:48 +0100
+Subject: Ignore parse errors for PKEY_AppUserModel_ToastActivatorCLSID
+
+Some shortcuts store this as a string UUID as opposed to VT_CLSID,
+hitting NOTREACHED() and sometimes breaking parsing in Electron.
+Ignore this error instead.
+
+Bug: N/A
+Change-Id: I9fc472212b2d3afac2c8e18a2159bc2d50bbdf98
+
+diff --git a/AUTHORS b/AUTHORS
+index 55dc38c1448c1960b802c136018c8be22ed61c18..5cd195df3650331fbfd62b2f964368b5f3217f3c 100644
+--- a/AUTHORS
++++ b/AUTHORS
+@@ -337,6 +337,7 @@ David Futcher <david.mike.futcher@gmail.com>
+ David Jin <davidjin@amazon.com>
+ David Lechner <david@pybricks.com>
+ David Leen <davileen@amazon.com>
++David Lönnhager <dv.lnh.d@gmail.com>
+ David Manouchehri <david@davidmanouchehri.com>
+ David McAllister <mcdavid@amazon.com>
+ David Michael Barr <david.barr@samsung.com>
+diff --git a/base/win/shortcut.cc b/base/win/shortcut.cc
+index e790adb2f1d6529ac0dd77145f5da2796264c7ae..8a7edcfaf9af963468b4b42fe55a771fb31f13a2 100644
+--- a/base/win/shortcut.cc
++++ b/base/win/shortcut.cc
+@@ -342,8 +342,9 @@ bool ResolveShortcutProperties(const FilePath& shortcut_path,
+               *(pv_toast_activator_clsid.get().puuid));
+           break;
+         default:
+-          NOTREACHED() << "Unexpected variant type: "
+-                       << pv_toast_activator_clsid.get().vt;
++          // Shortcuts may use strings to represent the CLSID. This case is
++          // ignored.
++          break;
+       }
+     }
+   }
diff --git a/shell/common/api/electron_api_shell.cc b/shell/common/api/electron_api_shell.cc
index a8031264d7cdd..d6097e7efbb84 100644
--- a/shell/common/api/electron_api_shell.cc
+++ b/shell/common/api/electron_api_shell.cc
@@ -163,7 +163,8 @@ v8::Local<v8::Value> ReadShortcutLink(gin_helper::ErrorThrower thrower,
   options.Set("icon", properties.icon);
   options.Set("iconIndex", properties.icon_index);
   options.Set("appUserModelId", properties.app_id);
-  options.Set("toastActivatorClsid", properties.toast_activator_clsid);
+  if (properties.options & ShortcutProperties::PROPERTIES_TOAST_ACTIVATOR_CLSID)
+    options.Set("toastActivatorClsid", properties.toast_activator_clsid);
   return gin::ConvertToV8(thrower.isolate(), options);
 }
 #endif


Test patch: