fix(event-log): match embedded routes precisely in logger middleware#41942
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #41942 +/- ##
=======================================
Coverage 64.79% 64.79%
=======================================
Files 2740 2740
Lines 153125 153126 +1
Branches 35124 35125 +1
=======================================
+ Hits 99219 99220 +1
Misses 52009 52009
Partials 1897 1897
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Code Review Agent Run #539aa5Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Cherry-picks the AI-suggested fix from apache#41942. The embedded-dashboard detection classified events by checking whether the URL contained the substring `/embedded/`, which misclassified a regular dashboard whose slug is literally `embedded` (URL `/dashboard/embedded/`). Replace the generic substring check with a regex that matches only the actual embedded route shapes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
React Router matches the embedded routes without a trailing slash too, so `/dashboard/:idOrSlug/embedded` and `/embedded/:uuid` are valid embedded URLs. The regex introduced in apache#41942 required a trailing slash, so those events were classified with the wrong source. Make the trailing slash optional in both branches and add test coverage for the no-slash variants. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
SUMMARY
This implements a suggestion raised by a review bot on PR #41938.
The embedded-dashboard detection in
loggerMiddlewareclassified events by checking whether the URL contained the substring/embedded/. That check is too broad: a regular dashboard whose slug is literallyembedded(URL/dashboard/embedded/) also contains/embedded/, so its events were incorrectly tagged withsource: 'embedded_dashboard'instead ofsource: 'dashboard'.This replaces the generic substring check with a regular expression that matches only the actual embedded route shapes:
/dashboard/:idOrSlug/embedded//embedded/:uuid/As a result, regular dashboard events are no longer misclassified as embedded, while genuine embedded routes continue to be detected correctly.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — internal event-logging metadata change only.
TESTING INSTRUCTIONS
Unit tests were added in
superset-frontend/src/middleware/logger.test.tscovering source classification across paths:/dashboard/123/embedded/->embedded_dashboard/embedded/abc-def-uuid/->embedded_dashboard/dashboard/123/->dashboard/dashboard/embedded/(slug is literallyembedded) ->dashboardRun:
ADDITIONAL INFORMATION