Skip to content

Check multipart max_size during iteration#12216

Merged
Dreamsorcerer merged 14 commits intomasterfrom
check-multipart-length
Mar 10, 2026
Merged

Check multipart max_size during iteration#12216
Dreamsorcerer merged 14 commits intomasterfrom
check-multipart-length

Conversation

@Dreamsorcerer
Copy link
Copy Markdown
Member

No description provided.

@Dreamsorcerer Dreamsorcerer requested a review from asvetlov as a code owner March 7, 2026 19:19
@Dreamsorcerer Dreamsorcerer added bot:chronographer:skip This PR does not need to include a change note backport-3.13 Trigger automatic backporting to the 3.13 release branch by Patchback robot backport-3.14 Trigger automatic backporting to the 3.14 release branch by Patchback robot labels Mar 7, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 7, 2026

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
4405 1 4404 46
View the top 1 failed test(s) by shortest run time
tests.test_web_functional::test_app_max_client_size_form_decode[pyloop]
Stack Traces | 0.161s run time
aiohttp_client = <function aiohttp_client.<locals>.go at 0x7fcf4705bd00>

    #x1B[0m#x1B[94masync#x1B[39;49;00m #x1B[94mdef#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[92mtest_app_max_client_size_form_decode#x1B[39;49;00m(aiohttp_client: AiohttpClient) -> #x1B[94mNone#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
        #x1B[94masync#x1B[39;49;00m #x1B[94mdef#x1B[39;49;00m#x1B[90m #x1B[39;49;00m#x1B[92mhandler#x1B[39;49;00m(request: web.Request) -> NoReturn:#x1B[90m#x1B[39;49;00m
            #x1B[94mawait#x1B[39;49;00m request.post()#x1B[90m#x1B[39;49;00m
            #x1B[94massert#x1B[39;49;00m #x1B[94mFalse#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        app = web.Application()#x1B[90m#x1B[39;49;00m
        app.router.add_post(#x1B[33m"#x1B[39;49;00m#x1B[33m/#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, handler)#x1B[90m#x1B[39;49;00m
        client = #x1B[94mawait#x1B[39;49;00m aiohttp_client(app)#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        #x1B[94mwith#x1B[39;49;00m aiohttp.MultipartWriter(#x1B[33m"#x1B[39;49;00m#x1B[33mform-data#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m) #x1B[94mas#x1B[39;49;00m mp:#x1B[90m#x1B[39;49;00m
            #x1B[90m# Verify that entire multipart form can't exceed client size (not just each field).#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
            #x1B[94mfor#x1B[39;49;00m i #x1B[95min#x1B[39;49;00m #x1B[96mrange#x1B[39;49;00m(#x1B[94m3#x1B[39;49;00m):#x1B[90m#x1B[39;49;00m
                part = mp.append(gzip.compress(#x1B[33mb#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m#x1B[33mA#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m * #x1B[94m512000#x1B[39;49;00m))#x1B[90m#x1B[39;49;00m
                part.set_content_disposition(#x1B[33m"#x1B[39;49;00m#x1B[33mform-data#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, name=#x1B[33mf#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m#x1B[33mf#x1B[39;49;00m#x1B[33m{#x1B[39;49;00mi#x1B[33m}#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m
                part.headers[CONTENT_ENCODING] = #x1B[33m"#x1B[39;49;00m#x1B[33mgzip#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
            #x1B[94masync#x1B[39;49;00m #x1B[94mwith#x1B[39;49;00m client.post(#x1B[33m"#x1B[39;49;00m#x1B[33m/#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, data=mp) #x1B[94mas#x1B[39;49;00m resp:#x1B[90m#x1B[39;49;00m
>               #x1B[94massert#x1B[39;49;00m resp.status == #x1B[94m413#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31mE               AssertionError: assert 500 == 413#x1B[0m
#x1B[1m#x1B[31mE                +  where 500 = <ClientResponse(http://127.0.0.1:42375/) [500 Internal Server Error]>\n<CIMultiDictProxy('Content-Type': 'text/plain; charset=utf-8', 'Content-Length': '55', 'Date': 'Mon, 09 Mar 2026 02:20:42 GMT', 'Server': 'Python/3.10 aiohttp/4.0.0a2.dev0', 'Connection': 'close')>\n.status#x1B[0m

aiohttp_client = <function aiohttp_client.<locals>.go at 0x7fcf4705bd00>
app        = <Application 0x7fcf46bc8930>
client     = <aiohttp.test_utils.TestClient object at 0x7fcf4762af50>
handler    = <function test_app_max_client_size_form_decode.<locals>.handler at 0x7fcf47f1da20>
i          = 2
mp         = <aiohttp.multipart.MultipartWriter object at 0x7fcf4762a440>
part       = <aiohttp.payload.BytesPayload object at 0x7fcf4762b040>
resp       = <ClientResponse(http://127.0.0.1:42375/) [500 Internal Server Error]>
<CIMultiDictProxy('Content-Type': 'text/plain; c...: '55', 'Date': 'Mon, 09 Mar 2026 02:20:42 GMT', 'Server': 'Python/3.10 aiohttp/4.0.0a2.dev0', 'Connection': 'close')>


#x1B[1m#x1B[31mtests/test_web_functional.py#x1B[0m:1726: AssertionError

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 7, 2026

Merging this PR will not alter performance

✅ 59 untouched benchmarks


Comparing check-multipart-length (9237cda) with master (5fe9dfb)

Open in CodSpeed

@bdraco
Copy link
Copy Markdown
Member

bdraco commented Mar 10, 2026

So PR seems correct as-is. The test is just failing because it doesn't decompress, which is correct. It just needs a real large payload to trigger the production. The bytes/bytearray type issues should probably get ignores and be solved in a future PR.

@Dreamsorcerer Dreamsorcerer merged commit 9cc4b91 into master Mar 10, 2026
43 checks passed
@Dreamsorcerer Dreamsorcerer deleted the check-multipart-length branch March 10, 2026 20:59
@patchback
Copy link
Copy Markdown
Contributor

patchback bot commented Mar 10, 2026

Backport to 3.13: 💚 backport PR created

✅ Backport PR branch: patchback/backports/3.13/9cc4b917c54833a22f65edae7963d16a6eeb1f54/pr-12216

Backported as #12229

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

@patchback
Copy link
Copy Markdown
Contributor

patchback bot commented Mar 10, 2026

Backport to 3.14: 💚 backport PR created

✅ Backport PR branch: patchback/backports/3.14/9cc4b917c54833a22f65edae7963d16a6eeb1f54/pr-12216

Backported as #12230

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Mar 10, 2026
Dreamsorcerer added a commit that referenced this pull request Mar 10, 2026
…teration (#12230)

**This is a backport of PR #12216 as merged into master
(9cc4b91).**

---------

Co-authored-by: Sam Bull <git@sambull.org>
Dreamsorcerer added a commit that referenced this pull request Mar 10, 2026
…teration (#12229)

**This is a backport of PR #12216 as merged into master
(9cc4b91).**

---------

Co-authored-by: Sam Bull <git@sambull.org>
wavebyrd pushed a commit to wavebyrd/aiohttp that referenced this pull request Mar 13, 2026
…during iteration (aio-libs#12230)

**This is a backport of PR aio-libs#12216 as merged into master
(9cc4b91).**

---------

Co-authored-by: Sam Bull <git@sambull.org>
wavebyrd pushed a commit to wavebyrd/aiohttp that referenced this pull request Mar 13, 2026
…during iteration (aio-libs#12229)

**This is a backport of PR aio-libs#12216 as merged into master
(9cc4b91).**

---------

Co-authored-by: Sam Bull <git@sambull.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-3.13 Trigger automatic backporting to the 3.13 release branch by Patchback robot backport-3.14 Trigger automatic backporting to the 3.14 release branch by Patchback robot bot:chronographer:skip This PR does not need to include a change note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants