googleapis / googleapis/storage-testbench
parse_multipart crashes with KeyError when Content-Type header is missing in multipart body part
- Dominant language
- Python
- Stars
- 24
- Forks
- 38
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 1
Description
## Bug Description
`parse_multipart` in `testbench/common.py` (line 307) crashes with a `KeyError` when a multipart upload body part does not include a `Content-Type` header.
## Steps to Reproduce
Send a multipart upload request where the media body part omits the `Content-Type` header. This is what the [`google-cloud-storage` Rust crate](https://github.com/yoshidan/google-cloud-rust) does when calling `write_object(...).send_buffered()`.
## Error
```
File "/opt/storage-testbench/testbench/common.py", line 307, in parse_multipart
content_type = {"content-type": headers[content_type_key].decode("utf-8")}
~~~~~~~^^^^^^^^^^^^^^^^^^
KeyError: b'content-type'
```
## Expected Behavior
Per RFC 2046, a missing `Content-Type` in a body part should default to `text/plain` (or `application/octet-stream` for GCS media). The testbench should handle this gracefully rather than crashing.
The real GCS API accepts these uploads without issue.
## Environment
- storage-testbench Docker image: `gcr.io/cloud-devrel-public-resources/storage-testbench:latest` (pulled 2026-05-15)
- Client: `google-cloud-storage` Rust crate (google-cloud-rust)
Contributor guide
Assessment
This issue has not been assessed yet.