← baseline_full_v2

requests_7309

failed NO_PATCH NO_PATCH UNSUBMITTED empty_patch(None) · None tool calls · 0 s · psf/requests

Task input

Fix malformed value parsing for Content-Type

This PR addresses https://github.com/psf/requests/issues/6646 by cleaning up `_parse_content_type_header`. Instead of setting a default that we can't use in practice, we now skip value assignment completely if the value is malformed. Every RFC from 1521 to 9110 is clear that an `=` is required for a valid parameter. If it doesn't exist, we need to ignore it.

Tool calls (0)

#ToolArgumentsResult
No trace captured.

Test output

show
..s..................................................................... [ 32%]
..................................................................F
=================================== FAILURES ===================================
_ test__parse_content_type_header[multipart/form-data; boundary = something ; boundary2='something_else' ; no_equals -expected4] _

value = "multipart/form-data; boundary = something ; boundary2='something_else' ; no_equals "
expected = ('multipart/form-data', {'boundary': 'something', 'boundary2': 'something_else'})

    @pytest.mark.parametrize(
        "value, expected",
        (
            ("application/xml", ("application/xml", {})),
            (
                "application/json ; charset=utf-8",
                ("application/json", {"charset": "utf-8"}),
            ),
            (
                "application/json ; Charset=utf-8",
                ("application/json", {"charset": "utf-8"}),
            ),
            ("text/plain", ("text/plain", {})),
            (
                "multipart/form-data; boundary = something ; boundary2='something_else' ; no_equals ",
                (
                    "multipart/form-data",
                    {
                        "boundary": "something",
                        "boundary2": "something_else",
                    },
                ),
            ),
            (
                'multipart/form-data; boundary = something ; boundary2="something_else" ; no_equals ',
                (
                    "multipart/form-data",
                    {
                        "boundary": "something",
                        "boundary2": "something_else",
                    },
                ),
            ),
            (
                "multipart/form-data; boundary = something ; 'boundary2=something_else' ; no_equals ",
                (
                    "multipart/form-data",
                    {
                        "boundary": "something",
                        "boundary2": "something_else",
                    },
                ),
            ),
            (
                'multipart/form-data; boundary = something ; "boundary2=something_else" ; no_equals ',
                (
                    "multipart/form-data",
                    {
                        "boundary": "something",
                        "boundary2": "something_else",
                    },
                ),
            ),
            ("application/json ; ; ", ("application/json", {})),
        ),
    )
    def test__parse_content_type_header(value, expected):
>       assert _parse_content_type_header(value) == expected
E       AssertionError: assert ('multipart/f...quals': True}) == ('multipart/f...ething_else'})
E         
E         At index 1 diff: {'boundary': 'something', 'boundary2': 'something_else', 'no_equals': True} != {'boundary': 'something', 'boundary2': 'something_else'}
E         Use -v to get more diff

tests/test_utils.py:633: AssertionError
=============================== warnings summary ===============================
../../../../../../../Users/jp/repos/kaggle-gemini-coding-agent-post-training/.envs/requests/lib/python3.13/site-packages/_pytest/config/__init__.py:1464
  /Users/jp/repos/kaggle-gemini-coding-agent-post-training/.envs/requests/lib/python3.13/site-packages/_pytest/config/__init__.py:1464: PytestConfigWarning: Unknown config option: timeout
  
    self._warn_or_fail_if_strict(f"Unknown config option: {key}\n")

tests/test_utils.py::TestContentEncodingDetection::test_none
tests/test_utils.py::TestContentEncodingDetection::test_pragmas[<meta charset="UTF-8">]
tests/test_utils.py::TestContentEncodingDetection::test_pragmas[<meta http-equiv="Content-type" content="text/html;charset=UTF-8">]
tests/test_utils.py::TestContentEncodingDetection::test_pragmas[<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />]
tests/test_utils.py::TestContentEncodingDetection::test_pragmas[<?xml version="1.0" encoding="UTF-8"?>]
tests/test_utils.py::TestContentEncodingDetection::test_precedence
  /tmp/swe_work/baseline_full_v2/requests_7309/b/workspace/src/requests/utils.py:484: DeprecationWarning: In requests 3.0, get_encodings_from_content will be removed. For more information, please see the discussion on issue #2266. (This warning should only appear once.)
    warnings.warn(

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
1 failed, 137 passed, 1 skipped, 7 warnings in 0.15s
[2026-09-23 20:58:11,751] WARNING in core: flasgger is not installed; serving the static landing page at / and skipping the Swagger UI and /spec.json.