Skip to content

Reject bool for max_size and header limit args - #326

Closed
Pitchfork-and-Torch wants to merge 1 commit into
Kludex:mainfrom
Pitchfork-and-Torch:cook/reject-bool-max-size-header-limits
Closed

Pitchfork-and-Torch wants to merge 1 commit into
Kludex:mainfrom
Pitchfork-and-Torch:cook/reject-bool-max-size-header-limits

Conversation

@Pitchfork-and-Torch

@Pitchfork-and-Torch Pitchfork-and-Torch commented Sep 18, 2026

Copy link
Copy Markdown

Summary

bool is a numbers.Number and subclasses int, so:

  • max_size=True passed the existing isinstance(..., Number) and max_size >= 1 check (since True >= 1) and silently became size 1
  • max_header_count=True / max_header_size=True had no type checks and likewise became 1

This change rejects bool for max_size on OctetStreamParser, QuerystringParser, and MultipartParser, and adds int/non-bool validation for max_header_count / max_header_size.

Test plan

  • Added bool-reject tests for Querystring/OctetStream/Multipart parsers
  • Related max_size / header tests pass

Review in cubic

bool is a numbers.Number and subclasses int, so max_size=True and
max_header_count/max_header_size=True previously passed validation and
silently became 1. Reject bool explicitly for these limits.
@codspeed

codspeed Bot commented Sep 18, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 5 untouched benchmarks
⏩ 5 skipped benchmarks1


Comparing Pitchfork-and-Torch:cook/reject-bool-max-size-header-limits (a1f933e) with main (d9cb4c6)

Open in CodSpeed

Footnotes

  1. 5 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@Kludex Kludex closed this Sep 18, 2026
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.

2 participants