Skip to content

Raise a specific error for missing boundaries - #399

Closed
ryanduguid wants to merge 1 commit into
requests:mainfrom
ryanduguid:fix/multipart-missing-boundary
Closed

ryanduguid wants to merge 1 commit into
requests:mainfrom
ryanduguid:fix/multipart-missing-boundary

Conversation

@ryanduguid

@ryanduguid ryanduguid commented Oct 7, 2026 •

Copy link
Copy Markdown

Summary

Raise MissingBoundaryException when MultipartDecoder or from_response receives a multipart Content-Type without a recognised boundary, before body parsing. Export the exception through the existing public import layers and document it.

- AttributeError: 'MultipartDecoder' object has no attribute 'boundary'
+ MissingBoundaryException: Missing boundary parameter in multipart Content-Type

Closes #303.

Evidence

  • Before: Restoring only the original boundary discovery method gives six expected AttributeError failures and 43 passing controls.
    After: All 49 decoder tests pass on Python 2.7.18, 3.7.17, Windows 3.12.10 and the installed Linux 3.12.15 wheel. Coverage includes both construction routes, error precedence, empty and duplicate boundaries, quoted parameters, encoding and public exports.
  • Both py27-flake8 and py37-flake8 Tox environments pass. tox -e docs, the CI package builds and strict Twine checks pass on baseline and candidate. The rendered decoder page and installed wheel were inspected.

Risk

Callers catching AttributeError for a missing boundary must catch MissingBoundaryException. Recognised empty boundaries and the last recognised duplicate retain the existing parser behaviour, covered by regression controls.

Unverified

Full Tox fails with the same failures on master and this branch: Python 2.7 stops on the datetime.timezone import, Python 3.7 and 3.9 have two X509 deprecation failures, and Python 3.12 has 25 Betamax datetime.utcnow failures plus the two X509 failures. The full Windows suite, macOS, PyPy, noopenssl and upstream CI were not run.

Multipart responses without a recognised boundary currently fail with a
broad AttributeError during body parsing. Give callers a dedicated
exception from both decoder entry points and expose it through the
existing public import layers.

Document the error change and cover valid parsing, error precedence,
empty and duplicate boundaries, encoding and exports.

Closes #303
@ryanduguid ryanduguid closed this Oct 22, 2026
@ryanduguid
ryanduguid deleted the fix/multipart-missing-boundary branch October 27, 2026 01:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing boundary in content-type leads to Attribute Error

1 participant