{"record":{"id":"2937d340100608b4","repo":"reflex-dev/reflex","slug":"missing-boundary-in-multipart","errorCode":null,"errorMessage":"Missing boundary in multipart.","messagePattern":"Missing boundary in multipart\\.","errorType":"http","errorClass":"MultiPartException","httpStatus":null,"severity":"error","filePath":"packages/reflex-components-core/src/reflex_components_core/core/_upload.py","lineNumber":473,"sourceCode":"    async def parse(self) -> None:\n        \"\"\"Parse the incoming request stream and push chunks to the iterator.\n\n        Raises:\n            MultiPartException: If the request is not valid multipart upload data.\n            RuntimeError: If the upload handler exits before consuming all chunks.\n            HTTPException: If the bound-args field is not a valid JSON object.\n        \"\"\"\n        _, params = parse_options_header(self.headers[\"Content-Type\"])\n        charset = params.get(b\"charset\", \"utf-8\")\n        if isinstance(charset, bytes):\n            charset = charset.decode(\"latin-1\")\n        self._charset = charset\n\n        try:\n            boundary = params[b\"boundary\"]\n        except KeyError as err:\n            msg = \"Missing boundary in multipart.\"\n            raise MultiPartException(msg) from err\n\n        callbacks = {\n            \"on_part_begin\": self.on_part_begin,\n            \"on_part_data\": self.on_part_data,\n            \"on_part_end\": self.on_part_end,\n            \"on_header_field\": self.on_header_field,\n            \"on_header_value\": self.on_header_value,\n            \"on_header_end\": self.on_header_end,\n            \"on_headers_finished\": self.on_headers_finished,\n            \"on_end\": self.on_end,\n        }\n        parser = MultipartParser(boundary, cast(Any, callbacks))\n\n        async for chunk in self.stream:\n            self._stream_chunk_count += 1\n            parser.write(chunk)\n            await self._maybe_start_handler()\n            await self._flush_emitted_chunks()","sourceCodeStart":455,"sourceCodeEnd":491,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-components-core/src/reflex_components_core/core/_upload.py#L455-L491","documentation":"The streaming multipart parser requires a boundary parameter in the request's Content-Type header to split parts. Missing boundary raises MultiPartException chained from a KeyError when reading params[b\"boundary\"].","triggerScenarios":"A POST to the upload endpoint with Content-Type: multipart/form-data but no ; boundary=... parameter — e.g. manually set headers, stripped by a proxy, or a plain urlencoded body hitting the multipart route.","commonSituations":"fetch() with manually set Content-Type instead of letting the browser set it with the boundary; reverse proxies (nginx) stripping or rewriting the header; API gateways re-encoding bodies; unit tests posting raw bodies.","solutions":["Don't set Content-Type manually in fetch — pass FormData and let the browser add the boundary","Check proxy/gateway config for header rewriting on the upload route","In tests, use files=/data= parameters of HTTP clients so the boundary is generated"],"exampleFix":"// before\nfetch(url, {method:'POST', headers:{'Content-Type':'multipart/form-data'}, body: formData})\n\n// after\nfetch(url, {method:'POST', body: formData})  // browser sets boundary","handlingStrategy":"validation","validationCode":"ctype = request.headers.get(\"content-type\", \"\")\nassert \"boundary=\" in ctype, f\"bad content-type: {ctype}\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never set Content-Type manually when posting FormData","Verify proxies forward the full multipart Content-Type"],"tags":["upload","multipart","content-type","boundary"],"backgroundTag":"missing-multipart-boundary","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}