Skip to content

fix(hip): parameters=[(code, data)] loses values whose maker keyword differs from the data field name (#2352) - #2383

Merged
JarryShaw merged 1 commit into
mainfrom
fix/2352-hip-param-rebuild-keyword-mismatch
Oct 27, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/2352-hip-param-rebuild-keyword-mismatch

Conversation

@JarryShaw

@JarryShaw JarryShaw commented Oct 27, 2026 •

Copy link
Copy Markdown
Owner

What is the purpose of your pull request?

  • fix — bug fix

Description

Closes #2352.

  • Problem: HIP._make_hip_param's (code, value) branch rebuilds each parameter by expanding value as **kwargs into the maker. A parsed Data_Parameter is a Mapping, so it expands too — but 18 parameters' maker keywords are spelled differently from the data model's own field names (suite_id vs suites, group_id vs group, reg_type vs reg_request/reg_response/reg_failed/reg_info, a nested locator key colliding with _make_locator's own first parameter, and others), so those values silently fell back to the maker's default instead of reaching it, or raised AttributeError outright. HIP_TRANSFORM rebuilt as 0241000000000000, losing its suite_id — exactly the issue's repro.
  • Fix: a parsed Data_Parameter now goes to its maker positionally, through a new _make_hip_param_data helper shared with the OrderedMultiDict branch, which already called positionally and was already correct. The dict-form keyword API (parameters=[(code, {'suites': [...]})]) is untouched.
  • Test: tests/protocols/internet/test_hip_param_data_rebuild_2352_unit.py round-trips 19 cases over 18 renamed parameters through parse → rebuild via the (code, data) form — 15 makers whose renaming is detected mechanically from their keyword-only parameters against the data model's own field annotations, plus ROUTE_DST, ROUTE_VIA and LOCATOR_SET, hand-listed because their renaming is nested inside a sub-model the mechanical check can't see. A HOST_ID case with a non-ECDSA algorithm is included alongside the existing ECDSA one, which happens to round-trip either way. 36 of its subtests plus one further test fail on the parent commit.

@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) labels Oct 27, 2026
@JarryShaw JarryShaw moved this to In review in PyPCAPKit Oct 27, 2026
@github-actions github-actions Bot added this to the PyPCAPKit v1.5 milestone Oct 27, 2026
@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Coverage: 91.58% (unit tier, Python 3.15, 30fce1c4e, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 4 20 2 95.16%
pcapkit/const 19601 881 2620 867 92.12%
pcapkit/corekit 2596 74 818 37 96.51%
pcapkit/dumpkit 282 3 102 3 98.44%
pcapkit/foundation 3029 23 1050 25 98.82%
pcapkit/interface 138 4 52 3 96.32%
pcapkit/protocols 17461 218 4600 185 98.16%
pcapkit/toolkit 914 36 334 10 95.51%
pcapkit/utilities 502 7 144 5 98.14%
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

Review: GOOD TO GO at 930584693f86 (Sonnet). All 16+1 claimed renamed parameters independently re-derived and verified via real parse→rebuild round-trips (51 samples, every registry entry, byte-exact on head vs wrong on main for all 16 claims). Dict-form keyword API confirmed unchanged (51+36-case battery, byte-identical). Positional-call correctness confirmed via a static AST pass over all 49 makers — no field-order hazard. Fail-without-fix: 33 failures (32 subtests + 1 test) on main, exactly matching the fix's scope.

Found 2 MORE real casualties of the same bug beyond the original 16, both fixed by this same change but currently unpinned: LOCATOR_SET (nested locator key collides with the maker's first positional parameter, raising AttributeError on main) and raw-hi HOST_ID (algorithm lost on main, unlike the ECDSA-curve case that happens to round-trip). Also: the "derives the renaming set from the constructors" claim overclaims — the derivation exempts flags/lifetime by name and can't see LOCATOR_SET's nested-key collision, so it actually covers 15 of 17 mechanically. Fix dispatched for test coverage + prose corrections.

…differs from the data field name (#2352)

Problem: HIP._make_hip_param's (code, value) branch rebuilds each parameter
by expanding value as **kwargs into the maker. A parsed Data_Parameter is a
Mapping, so it expands too -- but 18 parameters' maker keywords are spelled
differently from the data model's own field names (suite_id vs suites,
group_id vs group, reg_type vs reg_request/reg_response/reg_failed/reg_info,
a nested locator key colliding with _make_locator's own first parameter, and
others), so those values silently fell back to the maker's default instead
of reaching it, or raised AttributeError outright. HIP_TRANSFORM rebuilt as
0241000000000000, losing its suite_id.

Fix: a parsed Data_Parameter now goes to its maker positionally, through a
new _make_hip_param_data helper shared with the OrderedMultiDict branch,
which already called positionally and was already correct. The dict-form
keyword API (parameters=[(code, {'suites': [...]})]) is untouched.

Test: tests/protocols/internet/test_hip_param_data_rebuild_2352_unit.py
round-trips 19 cases over 18 renamed parameters through parse -> rebuild via
the (code, data) form -- 15 makers whose renaming is detected mechanically
from their keyword-only parameters against the data model's own field
annotations, plus ROUTE_DST, ROUTE_VIA and LOCATOR_SET, hand-listed because
their renaming is nested inside a sub-model the mechanical check can't see.
A HOST_ID case with a non-ECDSA algorithm is included alongside the existing
ECDSA one, which happens to round-trip either way. 36 of its subtests plus
one further test fail on the parent commit.
@JarryShaw
JarryShaw force-pushed the fix/2352-hip-param-rebuild-keyword-mismatch branch from 9305846 to 30fce1c Compare October 27, 2026 13:14
@JarryShaw

Copy link
Copy Markdown
Owner Author

Amended 930584693 → 30fce1c4e: added the 2 bonus casualties as test cases (LOCATOR_SET's nested-key collision, raw-hi HOST_ID's algorithm loss — both fail-without-fix confirmed), corrected the overclaim about derivation (15 of 18 are mechanically derived, 3 hand-listed), fixed the subtest count (36, not 33) and the stale :data:CASES`` cross-reference. 57/57 tests pass.

All findings now addressed.

@JarryShaw

Copy link
Copy Markdown
Owner Author

Ready to merge.

Review: GOOD TO GO (Sonnet) at 30fce1c4e.
CI: Required checks passed, 0 failures (only the non-blocking experimental GraalPy leg still pending).
Mergeable, 0 unresolved threads.

@JarryShaw JarryShaw added the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 27, 2026
@JarryShaw
JarryShaw merged commit 4205b40 into main Oct 27, 2026
62 checks passed
@JarryShaw
JarryShaw deleted the fix/2352-hip-param-rebuild-keyword-mismatch branch October 27, 2026 15:08
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Oct 27, 2026
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 27, 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(hip): parameters=[(code, data)] loses values whose maker keyword differs from the data field name

1 participant