{"record":{"id":"d3ad72dead8be317","repo":"aio-libs/aiohttp","slug":"unknown-content-transfer-encoding-encoding","errorCode":null,"errorMessage":"unknown content transfer encoding: {encoding}","messagePattern":"unknown content transfer encoding: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"aiohttp/multipart.py","lineNumber":607,"sourceCode":"                suppress_deflate_header=True,\n            )\n            yield await d.decompress(data, max_length=self._max_decompress_size)\n            while d.data_available:\n                yield await d.decompress(b\"\", max_length=self._max_decompress_size)\n        else:\n            raise RuntimeError(f\"unknown content encoding: {encoding}\")\n\n    def _decode_content_transfer(self, data: bytes) -> bytes:\n        encoding = self.headers.get(CONTENT_TRANSFER_ENCODING, \"\").lower()\n\n        if encoding == \"base64\":\n            return base64.b64decode(data)\n        elif encoding == \"quoted-printable\":\n            return binascii.a2b_qp(data)\n        elif encoding in (\"binary\", \"8bit\", \"7bit\"):\n            return data\n        else:\n            raise RuntimeError(f\"unknown content transfer encoding: {encoding}\")\n\n    def get_charset(self, default: str) -> str:\n        \"\"\"Returns charset parameter from Content-Type header or default.\"\"\"\n        ctype = self.headers.get(CONTENT_TYPE, \"\")\n        mimetype = parse_mimetype(ctype)\n        return mimetype.parameters.get(\"charset\", self._default_charset or default)\n\n    @reify\n    def name(self) -> str | None:\n        \"\"\"Returns name specified in Content-Disposition header.\n\n        If the header is missing or malformed, returns None.\n        \"\"\"\n        _, params = parse_content_disposition(self.headers.get(CONTENT_DISPOSITION))\n        return content_disposition_filename(params, \"name\")\n\n    @reify\n    def filename(self) -> str | None:","sourceCodeStart":589,"sourceCodeEnd":625,"githubUrl":"https://github.com/aio-libs/aiohttp/blob/d041d4d0fd48c3f0832084d33be16cf1c4835f85/aiohttp/multipart.py#L589-L625","documentation":"Raised by _decode_content_transfer when the Content-Transfer-Encoding header is not one of base64, quoted-printable, binary, 8bit, or 7bit. Any other token (or a misspelling) yields a RuntimeError.","triggerScenarios":"A part carrying Content-Transfer-Encoding such as 'x-uuencode', 'uuencode', 'base-64' (hyphen), or any vendor extension; an empty/odd value that does not match the allowed set.","commonSituations":"Legacy MIME producers; copy-paste typos; MIME-aware mail clients repurposed for HTTP multipart; custom CTE tokens.","solutions":["Use one of base64, quoted-printable, binary, 8bit, 7bit for Content-Transfer-Encoding.","If you control the producer, drop CTE and send 8bit/binary with correct Content-Length.","Decode the unsupported transfer encoding externally before/after the reader touches it.","Catch RuntimeError and fall back to raw bytes when CTE is non-standard."],"exampleFix":"// before\nContent-Transfer-Encoding: x-uuencode\n\n// after\nContent-Transfer-Encoding: base64","handlingStrategy":"validation","validationCode":"SUPPORTED_CTE = {'base64', 'quoted-printable', 'binary', '8bit', '7bit'}\n\ndef assert_supported_cte(headers):\n    cte = headers.get('Content-Transfer-Encoding', '').lower()\n    if cte and cte not in SUPPORTED_CTE:\n        raise ValueError(f'Unsupported Content-Transfer-Encoding: {cte}')","typeGuard":"def is_supported_cte(value: object) -> bool:\n    return isinstance(value, str) and value.lower() in {'base64', 'quoted-printable', 'binary', '8bit', '7bit'}","tryCatchPattern":"try:\n    data = part._decode_content_transfer(raw)\nexcept RuntimeError as e:\n    if 'transfer encoding' in str(e):\n        data = raw  # treat as binary\n    else:\n        raise","preventionTips":["Use standard MIME CTE tokens (base64, quoted-printable, binary, 8bit, 7bit).","Spell tokens exactly (no 'base-64').","Drop CTE on the producer side if parts are already 8bit-clean."],"tags":["multipart","content-transfer-encoding","mime","decoding"],"backgroundTag":null,"analyzedSha":"d041d4d0fd48c3f0832084d33be16cf1c4835f85","analyzedAt":"2026-08-11T20:44:15.550Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}