Skip to content

fix(event-log): match embedded routes without trailing slash in logger middleware#42005

Open
luizotavio32 wants to merge 2 commits into
apache:masterfrom
luizotavio32:fix-embedded-route-trailing-slash
Open

fix(event-log): match embedded routes without trailing slash in logger middleware#42005
luizotavio32 wants to merge 2 commits into
apache:masterfrom
luizotavio32:fix-embedded-route-trailing-slash

Conversation

@luizotavio32

Copy link
Copy Markdown
Contributor

SUMMARY

Follow-up to #41942, which replaced the substring /embedded/ check in loggerMiddleware with a regex matching the actual embedded route shapes (/dashboard/:idOrSlug/embedded/ and /embedded/:uuid/).

That regex required a trailing slash after the slug/UUID. However, the embedded routes are registered non-strict in React Router (superset-frontend/src/embedded/index.tsx), so they also match without a final slash — e.g. /dashboard/123/embedded and /embedded/<uuid>. For those URLs the regex failed to match, so the events were classified with source: 'dashboard' (or omitted) instead of source: 'embedded_dashboard', misreporting embedded-dashboard usage in the event log.

This makes the trailing slash optional in both branches of the regex:

-  /\/dashboard\/[^/]+\/embedded\/|\/embedded\/[^/]+\//;
+  /\/dashboard\/[^/]+\/embedded\/?|\/embedded\/[^/]+\/?/;

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A — internal event-logging metadata change only.

TESTING INSTRUCTIONS

Unit tests in superset-frontend/src/middleware/logger.test.ts now cover the no-trailing-slash variants:

  • /dashboard/123/embedded -> embedded_dashboard
  • /embedded/abc-def-uuid -> embedded_dashboard

alongside the existing trailing-slash and regular-dashboard cases.

Run:

cd superset-frontend
npm run test -- src/middleware/logger.test.ts

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@bito-code-review

bito-code-review Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #7ad814

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 1cf7e7d..1cf7e7d
    • superset-frontend/src/middleware/logger.test.ts
    • superset-frontend/src/middleware/loggerMiddleware.ts
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@luizotavio32

Copy link
Copy Markdown
Contributor Author

CI note: playwright failures are unrelated to this change

The playwright-tests (chromium) failures are not caused by this PR (which only touches the event-log source classification regex in loggerMiddleware.ts and its unit test):

playwright-tests-experimental passed, and the change is covered by the unit tests in logger.test.ts. Happy to rebase once master stabilizes, or a maintainer can re-run the required job.

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>
@luizotavio32 luizotavio32 force-pushed the fix-embedded-route-trailing-slash branch from 1cf7e7d to 6ae4170 Compare July 13, 2026 20:35
@github-actions github-actions Bot removed the embedded label Jul 13, 2026
Comment thread superset-frontend/src/middleware/loggerMiddleware.ts Outdated
@bito-code-review

Copy link
Copy Markdown
Contributor

The flagged issue is correct. The current regex //dashboard/[^/]+/embedded/?|/embedded/[^/]+/?/ matches any string containing these patterns, allowing false positives like /dashboard/123/embeddedXYZ. To resolve this, you should enforce a segment boundary using a lookahead or by explicitly matching the end of the string or path delimiters.

To fix this, update the regex to require a boundary after the embedded segment:

const EMBEDDED_ROUTE_REGEX =
  /\/dashboard\/[^/]+\/embedded($|[/?#])|\/embedded\/[^/]+($|[/?#])/;

This ensures that embedded is followed by the end of the string, a slash, a question mark, or a hash, preventing partial matches on longer segments. There are no other comments on this PR to address.

superset-frontend/src/middleware/loggerMiddleware.ts

const EMBEDDED_ROUTE_REGEX =
  /\/dashboard\/[^/]+\/embedded($|[/?#])|\/embedded\/[^/]+($|[/?#])/;

@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.03%. Comparing base (18f1dd3) to head (63b181a).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #42005   +/-   ##
=======================================
  Coverage   65.03%   65.03%           
=======================================
  Files        2744     2744           
  Lines      153627   153627           
  Branches    35226    35226           
=======================================
  Hits        99910    99910           
  Misses      51810    51810           
  Partials     1907     1907           
Flag Coverage Δ
javascript 70.38% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

The optional trailing slash allowed the first branch to match prefixes
like `/dashboard/123/embeddedXYZ`, misclassifying them as embedded. Require
an end-of-segment boundary (`/`, `?`, `#`, or end of string) after
`embedded` and add test coverage.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@bito-code-review

bito-code-review Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #565415

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 6ae4170..63b181a
    • superset-frontend/src/middleware/logger.test.ts
    • superset-frontend/src/middleware/loggerMiddleware.ts
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants