Skip to content

fix(app): quote the url in the generated curl command - #2842

Open
shuvamk wants to merge 2 commits into
hyperdxio:mainfrom
shuvamk:claude/quote-curl-url
Open

fix(app): quote the url in the generated curl command#2842
shuvamk wants to merge 2 commits into
hyperdxio:mainfrom
shuvamk:claude/quote-curl-url

Conversation

@shuvamk

@shuvamk shuvamk commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Summary

CurlGenerator (packages/app/src/utils/curlGenerator.ts:209) appends params.url to the snippet unquoted, so Copy Request as Curl in the HTTP Request panel puts a command on the clipboard that the shell re-splits. For http.url = https://api.example.com/v1/search?q=checkout&page=2 it generates:

curl https://api.example.com/v1/search?q=checkout&page=2 \
 -X GET \
-H "accept: application/json"

Pasted into bash, the & ends the command: curl is backgrounded with the single argument https://api.example.com/v1/search?q=checkout, page=2 is silently dropped, and the continuation is severed from the method and the headers, which run as a second command and fail with -X: command not found (exit 127). Spaces, ;, $(…) and backticks in a URL go wrong the same way.

The file already has escapeStringPosix — the Chrome DevTools POSIX escaper — and uses it for --data-raw. This applies it to the URL as well.

The same argument arguably applies to header values: getCurlHeaders wraps them in double quotes but escapes only \ and ", leaving $ and backticks live. I left that alone to keep this to one concern — happy to send it separately if you want it.

Tests: a new packages/app/src/utils/__tests__/curlGenerator.test.ts covers the query-string case, three metacharacter URLs and the ANSI-C quoting branch. All five fail on main and pass with this change. make ci-unit and make ci-lint are green locally, with packages/app lint warnings unchanged at 661. Changeset included.

Screenshots or video

N/A — the change is to copied text, not to anything rendered.

How to test on Vercel preview

Preview routes: /search

Steps:

  1. Open /search, pick a source with HTTP spans, and click a row whose http.url carries two or more query parameters.
  2. Expand the HTTP Request accordion and click Copy Request as Curl.
  3. Paste the clipboard into a shell.
  4. Verify the URL is wrapped in single quotes and the whole snippet runs as one curl invocation, instead of the shell cutting it at the first & and reporting -X: command not found.

References

  • Linear Issue: N/A — external contribution, no Linear ticket
  • Related PRs: none

`CurlGenerator` interpolated `params.url` into the snippet unquoted, so any
shell metacharacter in the URL broke the command that "Copy Request as Curl"
puts on the clipboard. A query string is the common case:

    http.url = https://api.example.com/v1/search?q=checkout&page=2

pastes as `curl https://api.example.com/v1/search?q=checkout&page=2 \` — bash
splits on the `&`, so curl gets one argument ending at `q=checkout`, `page=2`
is dropped, and the backslash continuation is severed from the method and the
headers, which run as a second command and fail with `-X: command not found`.

`escapeStringPosix`, the Chrome DevTools escaper this file already uses for
`--data-raw`, is applied to the URL as well.

The same argument applies to header values, which `getCurlHeaders` wraps in
double quotes while escaping only `\` and `"`, leaving `$` and backticks live.
That is left alone here to keep this to one concern.
@changeset-bot

changeset-bot Bot commented Aug 8, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8682f56

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

@vercel

vercel Bot commented Aug 8, 2026

Copy link
Copy Markdown

@shuvamk is attempting to deploy a commit to the HyperDX Team on Vercel.

A member of the Team first needs to authorize it.

@greptile-apps

greptile-apps Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR updates “Copy Request as Curl” to POSIX-quote request URLs and adds regression coverage for query strings, shell metacharacters, and single quotes.

  • Applies the existing POSIX string escaper to generated curl URLs.
  • Adds focused unit tests for shell-sensitive URL values.
  • Adds a patch changeset for @hyperdx/app.

Confidence Score: 4/5

The PR does not yet appear safe to merge because generating the HTTP request curl command can still crash when its URL is nullish.

The HTTP panel passes its dynamically sourced URL to the new string escaper before checking whether request metadata is absent, so a nullish URL causes render-time curl generation to throw.

Files Needing Attention: packages/app/src/utils/curlGenerator.ts and packages/app/src/components/NetworkPropertyPanel.tsx

Important Files Changed

Filename Overview
packages/app/src/utils/curlGenerator.ts Routes the URL through the existing POSIX shell escaper.
packages/app/src/utils/tests/curlGenerator.test.ts Adds regression tests for query strings and shell metacharacters in URLs.
.changeset/quote-curl-url.md Documents the curl URL quoting fix as an application patch.

Reviews (2): Last reviewed commit: "Merge branch 'main' into claude/quote-cu..." | Re-trigger Greptile

): string {
let curlSnippet = 'curl ';
curlSnippet += params.url;
curlSnippet += escapeStringPosix(params.url);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Nullish URL crashes curl generation

When an HTTP event has a method or status but no http.url, NetworkPropertyPanel still calls CurlGenerator, and the new escapeStringPosix(params.url) call dereferences the nullish value, causing the HTTP Request panel to throw instead of displaying the available request metadata.

Fix in Claude Code Fix in Conductor Fix in Cursor Fix in Codex

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shuvamk would you mind addressing this one? Either here or with guards in NetworkPropertySubpanel?

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.

2 participants