#2902: fix(matrix): check if requestOwnUserVerification exists before calling
channel: matrix
Cluster:
Matrix Media Handling Fixes
## Summary
The crypto SDK may not have the `requestOwnUserVerification` function, causing a TypeError on startup when E2EE is enabled.
## Problem
When `channels.matrix.encryption: true` is set, the code calls `client.crypto.requestOwnUserVerification()` without checking if the function exists. This causes:
```
{"error":"TypeError: client.crypto.requestOwnUserVerification is not a function"}
```
## Solution
Add a runtime check to verify the function exists before calling it. If not supported, log a debug message instead of throwing.
## Testing
- Tested with E2EE enabled on self-hosted Synapse
- Bot starts without error
- Gracefully handles missing verification support
Fixes #2901
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR hardens Matrix E2EE startup by guarding the `client.crypto.requestOwnUserVerification()` call with a runtime `typeof === "function"` check, avoiding a `TypeError` on crypto SDK versions that don’t expose that API. When unsupported, it logs a debug message and continues startup normally, keeping the monitor flow unchanged aside from the verification request branch.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge; it adds a narrow runtime guard to prevent a startup crash on older/alternate Matrix crypto SDK implementations.
- Change is minimal and localized: it only checks method existence before calling and adds a debug log path; no behavior changes when the method exists, and the previous try/catch remains in place for other errors.
- No files require special attention
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#10313: fix(matrix): fallback to authenticated media download (Matrix v1.11+)
by iter-next · 2026-02-06
73.0%
#8852: fix(matrix): Await mxcToHttp to properly detect authenticated media...
by emadomedher · 2026-02-04
72.1%
#20025: Fix Matrix messages silently dropped due to zero startup grace
by Clawborn · 2026-02-18
70.9%
#20278: Fix/matrix missing bot sdk dependency
by saurav470 · 2026-02-18
70.5%
#7842: Fix Matrix mention detection for Element client (formatted_body links)
by emadomedher · 2026-02-03
68.3%
#10721: fix for matrix media: destructure downloadContent return value in m...
by mklasen · 2026-02-06
67.3%
#7845: Fix Matrix mention detection with URL-encoded user IDs
by emadomedher · 2026-02-03
67.2%
#12077: Matrix: stabilize E2EE verification and modularize SDK
by gumadeiras · 2026-02-08
66.8%
#10606: fix(matrix): keep room IDs without :server suffix as-is during reso...
by majorminors · 2026-02-06
65.4%
#8779: fix(security): use constant-time comparison for token validation
by hleliofficiel · 2026-02-04
65.1%