Blazor WASM: PlatformNotSupportedException is not handled in license validation
Sub-issue of LuckyPennySoftware/AutoMapper#4659.
Problem
On Blazor WebAssembly and other client platforms, RSA isn't supported. JsonWebTokenHandler.ValidateTokenAsync returns a failed result whose Exception is SecurityTokenInvalidSignatureException (IDX10511), with a PlatformNotSupportedException caught inside it. Users get a critical-level "Error validating the Lucky Penny software license key" plus a signature error.
MediatR has no handling for this today: src/MediatR/Licensing/LicenseAccessor.cs ValidateKey doesn't catch PlatformNotSupportedException at all. AutoMapper has a catch, but it doesn't work either, because the exception isn't thrown.
Blazor WASM and client platforms account for 7 of the 26 license support cases across both products.
Fix
Match the AutoMapper fix:
- When
!validateResult.IsValid, check whethervalidateResult.Exceptionhas aPlatformNotSupportedExceptionanywhere inside it (walkInnerException, and handleAggregateException). - Also add a
catch (PlatformNotSupportedException)around validation for platforms where it is thrown directly. - In both cases, log an informational message pointing to MediatR's client redistribution guidance, not
LogCritical.
Tests
- Unit test: a validation result whose exception contains a nested
PlatformNotSupportedException→ info-level message, and no critical log. - Manual: Blazor WASM sample with a license key set → friendly message only.
Generated with Claude Code
Source: LuckyPennySoftware/MediatR