fix(copy): return 400 when /copy body is not form-encoded - #275
Merged
Merged
Conversation
…-encoded
COR-1 daily review (2026-05-07) surfaced 5 production POST 500s on
/copy/scdemos/demo[/about-us.html] with unhandled:
TypeError: Unrecognized Content-Type header value. FormData can only
parse the following MIME types: multipart/form-data,
application/x-www-form-urlencoded
Cloudflare's req.formData() throws synchronously on unsupported MIME
types. The throw was bubbling out of the worker as a 500. Wrap it in
try/catch and return a structured 400 via the existing { error } shape.
Coralogix query (last 24h):
source logs last 24h
| filter \$d.ScriptName == 'da-admin'
| filter \$d.Outcome == 'exception'
Co-Authored-By: Paperclip <noreply@paperclip.ing>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
bosschaert
approved these changes
May 7, 2026
adobe-bot
pushed a commit
that referenced
this pull request
May 7, 2026
## [1.7.3](v1.7.2...v1.7.3) (2026-05-07) ### Bug Fixes * **copy:** return 400 instead of 500 when /copy POST body is not form-encoded ([#275](#275)) ([a951f0c](a951f0c))
Collaborator
|
🎉 This PR is included in version 1.7.3 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Today's da-admin daily log review (24h ending 2026-05-07) surfaced 5 production POST 500s on
/copy/scdemos/demo[/about-us.html], every one with the same unhandled exception:Coralogix breakdown (filter
$d.ScriptName == 'da-admin' AND $d.Outcome == 'exception'):Root cause:
src/helpers/copy.jscallsawait req.formData()unguarded. Cloudflare workers'FormDataparser throws synchronously on unsupported MIME types, the throw bubbles into the worker runtime, and the client gets a 500 instead of a 4xx.What
req.formData()intry/catchand return the existing{ error }shape with status 400 + a clear message.TypeErrorand asserts the handler returns400with aContent-Typeerror message. Test fails onmain, passes after the fix.The route layer (
src/routes/copy.js) already doesif (details.error) return details.error;, so no route changes are needed.Verification
copy.jshelper coverage: 100% statements, 81.81% branches.npx eslint src/helpers/copy.js test/routes/copy.test.js→ clean.Out of scope
The same unguarded
req.formData()pattern exists inmove.js,source.js,delete.js,rename.js,kv/put.js. None of them surfaced in today's logs, so this PR scopes to/copyonly — fix the rest lazily as they appear in future daily reviews.