You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e3f24b9
Browse filesBrowse the repository at this point in the historyBrowse files
fix(dashboards): preserve multi-line SQL when replaying a search (#3382)
## Summary
Multi-line SQL in a dashboard's "Replay search" or drill-down link lost its line breaks as soon as the search page updated its URL, for example on a time-range change. A query like ServiceName = 'x' and + newline + SeverityText = 'error' became ...andSeverityText... and failed with a ClickHouse syntax error.
Cause: buildEventsSearchUrl built the /search URL with a plain URLSearchParams, which encodes values once. The search page's where, select and filters parsers (parseAsStringEncoded / parseAsJsonEncoded) expect two encoding layers. With only one, the first URL write on the search page re-rendered where with a raw newline. nuqs doesn't escape newlines, so the browser stripped it, and nuqs then re-read the joined value into state. The same missing layer also corrupted literal %XX text in values (a%20b was read as a b).
Fix: buildEventsSearchUrl now encodes where, select and filters with the same serializer the parsers use. It lives in a new nuqs-free module, utils/urlParamEncoding.ts, which queryParsers.ts now uses too. This fixes the four dashboard and chart links that use this builder:
- tile Replay search
- the time chart View All Events drill-down
- table row click-through
- the heatmap event-deltas link
Old single-encoded links still parse. Other /search link builders (generateSearchUrl, copyRowUrl, service map, LLM dashboard) have the same problem and will be handled in a follow-up.
## How to reproduce
Starting point: play.hyperdx.io
On main:
1. Create a dashboard and add a line tile on a logs source.
2. Set the where language to SQL and enter ServiceName != '' AND, then press Shift+Enter, then SeverityText != ''. The line break must be the only whitespace between AND and SeverityText. Save the tile.
3. Hover the tile and click Replay search. Results load.
4. Change the time range, e.g. to "Last 1 days".
5. The where box shows a single line (...ANDSeverityText...) and the search fails with a syntax error.
On this branch:
1. Repeat steps 1–4. The where box keeps both lines and results load.
## How to test on Vercel preview
Preview routes: /dashboards
Steps:
1. Create a new dashboard and add a line tile on the logs source.
2. Set the where language to SQL and enter ServiceName != '' AND, press Shift+Enter, then enter SeverityText != ''. Save the tile.
3. Hover the tile and click Replay search. In the new tab, wait for results.
4. Open the time picker and select "Last 1 days".
5. Verify the where editor shows two lines and the results table has rows, with no error.
References
- Linear Issue: Closes HDX-5726
- Related PRs:
constLINE_SQL=`SELECT toStartOfInterval(Timestamp, INTERVAL {intervalSeconds:Int64} SECOND) AS ts, count() AS count FROM default.e2e_otel_logs WHERE Timestamp >= fromUnixTimestamp64Milli({startDateMilliseconds:Int64}) AND Timestamp < fromUnixTimestamp64Milli({endDateMilliseconds:Int64}) GROUP BY ts ORDER BY ts ASC`;
0 commit comments