Skip to content

fix(hip): from_data no longer reads alias before _info is set (#1184) - #1188

Merged
JarryShaw merged 1 commit into
mainfrom
fix/1184-hip-from-data-alias
Oct 7, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/1184-hip-from-data-alias

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner
  • Searched for similar pull requests
  • Followed the coding style (make pylint, make mypy, make isort) — run with the Makefile flags on the touched files: isort clean, mypy clean, pylint no new messages
  • make test passes, and a test case covers the change — the modules listed below only, not the whole suite
  • Added a changelog entry under docs/source/changelog/ and regenerated CHANGELOG.md, if the change is user-visible — N/A, added centrally

What is the purpose of your pull request?

  • fix — corrects a defect

Description of your pull request and other information

Closes #1184. Path: from_data → __post_init__ → unpack → HIP.read → Internet._decode_next_layer (internet.py:236) → HIP.alias → self._info, which Protocol.__post_init__ assigns only after read returns. read now sets self._info = hip just before decoding the next layer. alias is unchanged, since test_hip_unit.py pins it as reading _info. Standalone HIP parse and make hit the same error, and are fixed too.

Probe over the 49 HIP headers in options-internet.pcap:

Tests: new tests/protocols/internet/test_hip_from_data_alias_unit.py. Without the fix, all 6 subtests fail with the _info AttributeError; with it, 3 passed, 6 subtests passed. These also pass: test_hip_unit (34), the 5 other test_hip_*_unit modules, test_internet_unit, test_option_roundtrip_unit, and tests/project (389 passed, 1 skipped). run_unittest_leg.py protocols/internet reports 475 tests with 0 failures.

Outside an IPv6 extension chain, HIP.read ends in _decode_next_layer,
which builds the protocol chain from self.alias. alias reads
self._info.version, but __post_init__ assigns _info only after read
returns, so parsing or constructing a standalone HIP header, and
HIP.from_data over a parsed one, raised AttributeError. read now sets
_info just before decoding the next layer.

All 49 HIP headers in options-internet.pcap now rebuild byte for byte
through HIP.from_data (49 raised before).
@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 7, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Cross-review verdict on 6ad13e101: GOOD TO GO (ran on Sonnet; author Opus). Labelled review: good-to-go.

@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 7, 2026
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Coverage: 88.89% (unit tier, Python 3.14, 6ad13e101, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 4 20 4 93.55%
pcapkit/const 18757 1034 2342 845 90.24%
pcapkit/corekit 1878 91 580 22 94.34%
pcapkit/dumpkit 142 0 42 0 100.00%
pcapkit/foundation 2442 102 852 39 94.38%
pcapkit/interface 112 7 40 5 92.11%
pcapkit/protocols 15708 188 3974 163 98.19%
pcapkit/toolkit 487 65 144 1 85.42%
pcapkit/utilities 429 4 122 4 98.55%
pcapkit/vendor 4409 2359 1006 158 42.84%

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

@JarryShaw
JarryShaw merged commit e41b18a into main Oct 7, 2026
41 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Oct 7, 2026
@JarryShaw
JarryShaw deleted the fix/1184-hip-from-data-alias branch October 7, 2026 14:00
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 7, 2026
@JarryShaw JarryShaw added this to the PyPCAPKit v1.5 milestone Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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): from_data raises AttributeError, alias reads _info before it is set

1 participant