Skip to content

parse_multipart crashes with KeyError when Content-Type header is missing in multipart body part #801

@23Skidoo

Description

@23Skidoo

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 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions