Skip to content

fix(httpv2): accept a plain dict of SETTINGS (#2223) - #2241

Merged
JarryShaw merged 1 commit into
mainfrom
fix/2223-http2-settings-dict
Oct 26, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/2223-http2-settings-dict

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

What is the purpose of your pull request?

  • fix — bug fix

Description

Closes #2223. HTTP._make_http_settings accepted a dict but always called settings.items(multi=True), which only MultiDict has, so {1: 2} raised TypeError: dict.items() takes no keyword arguments.

  • Fix: it calls items(multi=True) on a MultiDict, OrderedMultiDict included, and plain items() otherwise. The annotation and Args: name a plain dict.
  • Test: tests/protocols/application/test_httpv2_settings_dict_2223_unit.py.
    • {1: 2} and {Setting.HEADER_TABLE_SIZE: 2} build 000006040000000000000100000002, the same octets as the list.
    • Insertion order is kept, and the built frame parses back.
    • An empty dict builds an empty frame.
    • An OrderedMultiDict keeps repeated identifiers.
  • Fail-without-fix: on origin/main, 5 failed with the TypeError.
  • Tests run: tests/protocols/application gives 249 passed. The docstring contract and tier guard give 140 passed.

@JarryShaw JarryShaw added bug Issues reporting a defect (set by the bug report template; a default, not an assessment) fix Pull requests that fix a defect (fix: subject prefix) review: running A cross-review is in flight against the current head - no verdict yet labels Oct 26, 2026
@JarryShaw JarryShaw added fix Pull requests that fix a defect (fix: subject prefix) review: running A cross-review is in flight against the current head - no verdict yet labels Oct 26, 2026
@JarryShaw JarryShaw added this to the PyPCAPKit v1.5 milestone Oct 26, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Review: NEEDS CHANGES at 8e0d2872e (Sonnet).

  • Tier marker: remove __tier__ = 'ALL'. tests/_tiers.py keeps ALL curated: interpreter-sensitive behaviour, round-trip tables and a smoke slice. This is a pure-Python construction regression test, and its sibling test_httpv2_settings_list_1140_unit.py carries no marker.
  • Fix confirmed: {1: 2} builds 000006040000000000000100000002. MultiDict and OrderedMultiDict still use multi=True, and repeated ids build the same frame for both.
  • Fail-without-fix: with main's httpv2.py, 5 failed with the TypeError. No other items(multi=True) site takes user input.

@JarryShaw JarryShaw added review: needs-changes Cross-review at the current head says changes are required; see the verdict comment and removed review: running A cross-review is in flight against the current head - no verdict yet labels Oct 26, 2026
HTTP._make_http_settings took a dict branch but called
settings.items(multi=True), so a plain dict raised a stdlib TypeError.

Call items(multi=True) only on a MultiDict, and plain items() otherwise.
Widen the settings annotation and Args to name dict.

Test: a plain dict builds the same octets as a list of pairs, keeps
insertion order and parses back; an OrderedMultiDict keeps repeated ids.
@JarryShaw JarryShaw removed the review: needs-changes Cross-review at the current head says changes are required; see the verdict comment label Oct 26, 2026
@JarryShaw
JarryShaw force-pushed the fix/2223-http2-settings-dict branch from 8e0d287 to 9ce7f89 Compare October 26, 2026 03:55
@JarryShaw JarryShaw added the review: running A cross-review is in flight against the current head - no verdict yet label Oct 26, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Review: GOOD TO GO at 9ce7f89f7 (Sonnet delta review of 8e0d2872e→9ce7f89f7).

  • Delta: only the __tier__ = 'ALL' marker and its comment are removed.
  • Tests: the tier guard plus the new test give 138 passed. The earlier fix review stands.

@JarryShaw JarryShaw added review: good-to-go Cross-review at the current head says ready; CI state is separate and removed review: running A cross-review is in flight against the current head - no verdict yet labels Oct 26, 2026
@JarryShaw JarryShaw moved this to In review in PyPCAPKit Oct 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage: 91.56% (unit tier, Python 3.15, 9ce7f89f7, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 4 20 2 95.16%
pcapkit/const 19599 881 2618 867 92.11%
pcapkit/corekit 2589 74 816 37 96.51%
pcapkit/dumpkit 282 3 102 3 98.44%
pcapkit/foundation 2994 23 1038 25 98.81%
pcapkit/interface 138 4 52 3 96.32%
pcapkit/protocols 17434 218 4584 185 98.15%
pcapkit/toolkit 869 36 298 10 95.20%
pcapkit/utilities 504 7 146 5 98.15%
pcapkit/vendor 4432 1988 1018 167 51.87%

Per-file detail: the coverage-html artifact of this run.

@JarryShaw

Copy link
Copy Markdown
Owner Author

Ready to merge at 9ce7f89f7. Closes #2223.

  • Review: Sonnet GOOD TO GO, after one NEEDS CHANGES round, which dropped the ALL tier marker.
  • CI: all checks complete, Required checks passed SUCCESS, 0 failed.
  • KTLO: 12 legs, no warnings.
  • Ordering: merged into main and run. protocols leg: 1929 tests, 0 failures.
  • Conflicts: none against the current main.

@JarryShaw
JarryShaw merged commit b4f993e into main Oct 26, 2026
63 checks passed
@JarryShaw
JarryShaw deleted the fix/2223-http2-settings-dict branch October 26, 2026 14:49
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Oct 26, 2026
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issues reporting a defect (set by the bug report template; a default, not an assessment) fix Pull requests that fix a defect (fix: subject prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

fix(httpv2): a plain dict of SETTINGS crashes on items(multi=True)

1 participant