Skip to content

[wrangler] Split cloudchamber curl headers on the first colon only - #14815

Merged
petebacondarwin merged 2 commits into
cloudflare:mainfrom
chinesepowered:fix-cloudchamber-curl-header-parsing
Jul 27, 2026
Merged

[wrangler] Split cloudchamber curl headers on the first colon only#14815
petebacondarwin merged 2 commits into
cloudflare:mainfrom
chinesepowered:fix-cloudchamber-curl-header-parsing

Conversation

@chinesepowered

Copy link
Copy Markdown
Contributor

wrangler cloudchamber curl builds request headers by splitting each --header on every colon and taking only the segment between the first and second:

[now.toString().split(":")[0].trim()]: now.toString().split(":")[1].trim(),

Two consequences:

  1. A header whose value contains a colon is silently truncated — --header location:https://example.com/x is sent as location: https.
  2. A header with no colon (--header Foo) makes [1] undefined, so .trim() throws a TypeError, which is caught and printed instead of the request being made.

This splits on the first colon only and keeps the remainder as the value, matching what collectKeyValues.ts already does. Added two tests; both fail before this change.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: this is an internal correctness fix with no corresponding user-facing documentation.

@pkg-pr-new

pkg-pr-new Bot commented Jul 23, 2026

Copy link
Copy Markdown
@cloudflare/autoconfig

npm i https://pkg.pr.new/@cloudflare/autoconfig@14815

@cloudflare/config

npm i https://pkg.pr.new/@cloudflare/config@14815

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@14815

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/@cloudflare/deploy-helpers@14815

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@14815

miniflare

npm i https://pkg.pr.new/miniflare@14815

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@14815

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@14815

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@14815

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@14815

@cloudflare/workers-auth

npm i https://pkg.pr.new/@cloudflare/workers-auth@14815

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@14815

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@14815

wrangler

npm i https://pkg.pr.new/wrangler@14815

commit: a464238

@chinesepowered
chinesepowered force-pushed the fix-cloudchamber-curl-header-parsing branch from c6a9852 to 602df6a Compare July 23, 2026 17:30
@chinesepowered
chinesepowered marked this pull request as ready for review July 23, 2026 17:30
@changeset-bot

changeset-bot Bot commented Jul 23, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a464238

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

This PR includes changesets to release 3 packages
Name Type
wrangler Patch
@cloudflare/vite-plugin Patch
@cloudflare/vitest-pool-workers 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

@workers-devprod
workers-devprod requested review from a team and NuroDev and removed request for a team July 23, 2026 17:30
@workers-devprod

workers-devprod commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/cloudchamber
  • ✅ @cloudflare/wrangler
Show detailed file reviewers

@devin-ai-integration devin-ai-integration Bot left a comment

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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@emily-shen

Copy link
Copy Markdown
Contributor

Thank you for you PR, but we are no longer considering PRs submitted without issues. If you believe this constitutes a valid, user-facing bug, please create a bug report with a minimal reproduction and we will triage it appropriately.

@petebacondarwin

Copy link
Copy Markdown
Contributor

Re-opening as this is a valid bug that now has an issue

@github-project-automation github-project-automation Bot moved this from Done to Untriaged in workers-sdk Jul 24, 2026
@petebacondarwin
petebacondarwin force-pushed the fix-cloudchamber-curl-header-parsing branch from 602df6a to 72d351b Compare July 24, 2026 10:15
@petebacondarwin
petebacondarwin requested review from petebacondarwin and removed request for NuroDev July 24, 2026 10:15
Comment thread packages/wrangler/src/__tests__/cloudchamber/curl.test.ts Outdated
@github-project-automation github-project-automation Bot moved this from Untriaged to In Review in workers-sdk Jul 24, 2026
@chinesepowered

Copy link
Copy Markdown
Contributor Author

Thanks for reopening this, and you're right — that test asserted the wrong behaviour. A colon-less --header is malformed input, not something to accept silently.

Pushed a464238:

  • --header without a colon (or with an empty name) now throws a UserError: Invalid header "something". Headers must be in the form of --header <name>:<value>
  • Header parsing moved out of the try block. The existing catch turns everything into logRaw(String(error)), so a validation error raised inside it would have been printed as a request failure rather than surfacing properly — that's also why the original TypeError was swallowed instead of thrown.
  • The bad test is replaced by two that assert the error, one for a missing colon and one for a missing name. The colon-in-value coverage is unchanged.

Changeset updated to match, since it previously described the empty-value behaviour. Full curl.test.ts suite passes locally (11 tests).

@petebacondarwin

Copy link
Copy Markdown
Contributor

Just needs approval from the cloudchamber/containers team... cc @emily-shen

@workers-devprod workers-devprod left a comment

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.

Codeowners reviews satisfied

@github-project-automation github-project-automation Bot moved this from In Review to Approved in workers-sdk Jul 27, 2026
@petebacondarwin
petebacondarwin merged commit 09b8a44 into cloudflare:main Jul 27, 2026
72 of 74 checks passed
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants