Skip to content

fix(corekit): an untyped ListField packs the bytes it unpacks (#1489) - #1494

Merged
JarryShaw merged 1 commit into
mainfrom
fix/1489-listfield-untyped-pack
Oct 9, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/1489-listfield-untyped-pack

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

Please follow the guide below

What is the purpose of your pull request?

Tick the commit type your subject line carries.

  • fix — corrects a defect
  • feat — adds a feature
  • perf — changes performance, not behaviour
  • refactor — changes neither behaviour nor performance
  • test — tests only
  • docs — documentation only
  • ci — workflows or build tooling
  • release — bumps the version or rolls up a distribution
  • chore — anything else

Description of your pull request and other information

Without an item_type, ListField.unpack returns the field's octets as one bytes, but ListField.pack iterated that value and rejected each int, so pack(unpack(b)) raised FieldValueError. ListField.pack now writes such a bytes value as-is (pcapkit/corekit/fields/collections.py:145-146). A typed ListField still packs item by item, and an untyped list of bytes items is still joined. ListField.__init__ is untouched, and a trial merge with #1493 is clean.

  • Removes the Gap(1489, ...) row from tests/corekit/test_field_roundtrip_unit.py.
  • New tests/corekit/test_listfield_untyped_pack_1489_unit.py: 4 of its 9 checks fail on main's collections.py, and all pass with the fix.
  • Ran sequentially rather than make test: tests/corekit 474 passed; tests/protocols/test_capture_roundtrip_runtime.py 4 passed; tests/project 419 passed, 1 skipped; tests/test_docstring_contract.py 7 passed.
  • repr(frame.info.to_dict()) hashed per file over the 23 files in examples/captures is identical with and without the fix.

Closes #1489

Without an item_type, ListField.unpack returns the field's octets as one
bytes value, but ListField.pack iterated it and rejected each int. pack
now writes such a value as-is; typed ListFields are unchanged.

Drop the #1489 Gap row from the field round-trip table, and add
tests/corekit/test_listfield_untyped_pack_1489_unit.py.
@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 9, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Verdict: GOOD TO GO at e220f17f5. Cross-reviewed on Sonnet; the author ran on Opus.

  • The fix works. I measured it myself: on origin/main sources the new test file gives 4 failed, 5 passed. At head, that file plus test_field_roundtrip_unit.py gives 14 passed, 739 subtests, and only the Gap(1489…) row is removed.
  • The shortcut skips nothing. It fires only for an untyped field given bytes. OptionField and ChunkListField unpack to lists, so their schema packing is unchanged. The per-capture to_dict() hashes are identical across all 23 captures.
  • It merges cleanly with fix(corekit): give unnamed ListField, PayloadField and SchemaField a default name (#1491) #1493, which edits ListField.__init__ in the same file (git merge-tree).
  • Tests: tests/corekit 474 passed; the SCTP tests 71 passed; tests/project 419 passed.

Non-blocking:

  • Like a typed ListField, an untyped one neither pads nor truncates bytes to length, which differs from BytesField. The round trip is unaffected.
  • bytearray and memoryview still take the item path.

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

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Coverage: 89.65% (unit tier, Python 3.14, e220f17f5, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 4 20 4 93.55%
pcapkit/const 18795 958 2356 871 90.99%
pcapkit/corekit 2109 68 674 29 96.16%
pcapkit/dumpkit 242 2 88 2 98.79%
pcapkit/foundation 2648 98 930 48 94.80%
pcapkit/interface 112 7 40 5 92.11%
pcapkit/protocols 17086 238 4628 190 97.98%
pcapkit/toolkit 539 74 168 3 84.58%
pcapkit/utilities 431 4 124 4 98.56%
pcapkit/vendor 4409 2342 1006 157 43.25%

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

@JarryShaw
JarryShaw merged commit 00aa1fc into main Oct 9, 2026
41 checks passed
@JarryShaw
JarryShaw deleted the fix/1489-listfield-untyped-pack branch October 9, 2026 20:06
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 9, 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(corekit): a ListField without item_type cannot pack what it unpacks

1 participant