refactor: URL generation for application state#1772
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
PR Review: URL State CompressionOverall: Solid approach with good backwards compatibility design and comprehensive tests. Issues
Positives
|
Resolved conflict in DBDashboardPage.tsx: kept useBrandDisplayName from main and parseAsCompressedString from our branch (replacing old parseAsStringWithNewLines). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
PR Review: URL CompressionApproach looks solid — LZ-prefix guard for string params, backwards-compatible fallback chain, good test coverage. Two bugs to address: Bug 1: decompressStringParam silent corruption on failed decompression In urlCompression.ts, when a ~-prefixed value fails LZString decompression, the function falls through and returns the raw string (e.g. ~brokendata) instead of a safe fallback: Fix: return null (or empty string) when the prefixed value fails decompression, not the raw prefixed string. Bug 2: parseAsCompressedString.parse never returns null — nuqs default is unreachable decompressStringParam always returns string, so the nuqs parser can never signal "use default". Callers using .withDefault('') won't get their default for corrupted/invalid values. Fix: Change decompressStringParam to return string | null (returning null for unrecoverable values), and update parseAsCompressedString.parse accordingly. Minor: decompressUrlParam has no format prefix (inconsistency) JSON params use try-LZString-first with no LZ_PREFIX, relying on the fact that old JSON always contains [, {, " (chars outside LZString's alphabet). Works in practice, but inconsistent with how string params are handled. Low risk but worth aligning for maintainability. Note: E2E shows 1 failing test from the CI run — worth confirming that's unrelated before merge. |
E2E Test Results✅ All tests passed • 70 passed • 4 skipped • 806s
Tests ran across 4 shards in parallel. |
Fixes: HDX-3184
Problem
HyperDX URLs can become very long due to JSON-encoded state in query parameters (filters, SQL clauses, chart configs). This caused two issues:
Solution
Compress all URL parameters using https://github.com/pieroxy/lz-string's compressToEncodedURIComponent, which:
Changes
Backwards Compatibility
Existing bookmarks and shared URLs will continue to work. The decompressor tries LZ-string first; if that fails it falls back to plain JSON.parse (for JSON params) or the raw string value (for string params). The %0A → \n legacy encoding is also preserved.