From 91f576f723f3035e7770bd1687a0a9dcd11cd4ad Mon Sep 17 00:00:00 2001 From: juliet Date: Wed, 24 Jun 2026 20:01:06 -0400 Subject: [PATCH] fix(ui): tolerate malformed URI escapes in EntityWithPopover (#377) Co-authored-by: Claude Opus 4.7 (1M context) --- .../src/components/entities/EntityWithPopover.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/osprey_ui/src/components/entities/EntityWithPopover.tsx b/osprey_ui/src/components/entities/EntityWithPopover.tsx index 867ddca..f99d15a 100644 --- a/osprey_ui/src/components/entities/EntityWithPopover.tsx +++ b/osprey_ui/src/components/entities/EntityWithPopover.tsx @@ -103,8 +103,17 @@ const EntityWithPopover = ({ entityId, featureName, entityType }: EntityWithPopo }>(); const isRouteEntity = entityRouteType === entityType && entityRouteId === entityId; - const decodedEntityType = decodeURIComponent(entityType); - const decodedEntityId = decodeURIComponent(entityId); + // `decodeURIComponent` throws on malformed input (stray `%`, etc.). Fall + // back to the raw value so a bad ID doesn't crash the whole popover. + const safeDecode = (s: string): string => { + try { + return decodeURIComponent(s); + } catch { + return s; + } + }; + const decodedEntityType = safeDecode(entityType); + const decodedEntityId = safeDecode(entityId); const handleShowLabelDrawer = () => { updateShowLabelDrawer(true); -- 2.51.2