Skip to content

fix: Add better URL encoding for query params with special characters#1794

Open
teeohhem wants to merge 6 commits intomainfrom
tom/url-encode-json
Open

fix: Add better URL encoding for query params with special characters#1794
teeohhem wants to merge 6 commits intomainfrom
tom/url-encode-json

Conversation

@teeohhem
Copy link
Contributor

@teeohhem teeohhem commented Feb 24, 2026

Adds custom nuqs parsers (parseAsStringEncoded, parseAsJsonEncoded) that pre-encode values with encodeURIComponent, producing %XX sequences instead of + form-encoding. This protects against re-encoding + to %2B when sharing links, which was causing ClickHouse query errors when accessed from tools like Microsoft Teams.

Backward compatible: parsers fall back to plain JSON.parse for old-format URLs.

Test:

  • New URLs
  • Grab a play.hyperdx.io URL and change the source and domain in the URL. Proves "old" URLS still work.

I verified that links generated from this branch work as intended in Microsoft Teams, which was the original source of this report.

Fixes: HDX-3184

Adds custom nuqs parsers (parseAsStringEncoded, parseAsJsonEncoded) that
pre-encode values with encodeURIComponent, producing %XX sequences instead
of + form-encoding. This protects against Microsoft Teams re-encoding +
to %2B when sharing links, which was causing ClickHouse query errors.

Backward compatible: parsers fall back to plain JSON.parse for old-format URLs.

Co-authored-by: Cursor <cursoragent@cursor.com>
@vercel
Copy link

vercel bot commented Feb 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hyperdx-v2-oss-app Ready Ready Preview, Comment Feb 24, 2026 6:18pm

Request Review

@changeset-bot
Copy link

changeset-bot bot commented Feb 24, 2026

🦋 Changeset detected

Latest commit: 9199844

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@hyperdx/app Patch
@hyperdx/api Patch
@hyperdx/otel-collector Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Improve URL encoding for query parameters to handle special characters more effectively.
@github-actions
Copy link
Contributor

github-actions bot commented Feb 24, 2026

PR Review: fix: Add better URL encoding for query params with special characters

Reviewed by Claude Sonnet 4.6

The approach is correct — double-encoding via encodeURIComponent in serialize + decodeURIComponent in parse protects against Teams re-encoding + as %2B. Backward-compat fallback logic, test coverage, changeset, and component adoption all look good.

Minor:

  • ⚠️ parseAsStringEncoded.parse returns the raw value on malformed URI instead of null (nuqs convention) — deliberate robustness tradeoff, not blocking.

No critical issues. Ready to merge.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 24, 2026

E2E Test Results

All tests passed • 70 passed • 4 skipped • 861s

Status Count
✅ Passed 70
❌ Failed 0
⚠️ Flaky 1
⏭️ Skipped 4

Tests ran across 4 shards in parallel.

View full report →

@hyperdxio hyperdxio deleted a comment from github-actions bot Feb 24, 2026
@hyperdxio hyperdxio deleted a comment from github-actions bot Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant