Skip to content

fix(corekit): give back the octets read when a zero-filled list fails (#2705) - #2706

Merged
JarryShaw merged 1 commit into
mainfrom
fix/2705-ledger-restore
Nov 2, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
fix/2705-ledger-restore

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

What is the purpose of your pull request?

  • fix — corrects a defect

Description of your pull request and other information

This is #2701's review follow-up, which landed after that PR merged. _zero_fill_items debited the zero-pad ledger's octets-read count up front, and never gave it back when an item failed after the fill. On a synthetic schema, one failure took the count from 1000 to -997, and every later legitimate cut in that context was refused.

The fill is now a context manager, _zero_filled_items. ListField._unpack_items parses the items inside it. If an item raises, the octets-read count goes back to its value before the fill. The padding charge stays, as FieldBase charges do after a later failure, so repeated failed fills cannot each spend the whole allowance.

A new test checks the ledger after a failed fill, and it fails without the restore. The NOTE in HTTPv2._make_data is trimmed to two lines.

Closes #2705

…#2705)

- _zero_fill_items debited the zeros from the ledger's octets read before the
  items were parsed and never restored them when an item raised, so one failed
  list lowered the allowance of every later cut in the context. It is now the
  context manager _zero_filled_items, ListField.unpack reads the items inside
  it, and a failure sets the octets read back; the fill stays charged.
- Trimmed the NOTE in HTTPv2._make_data to two lines.

The corekit and application modules pass; the new test fails without the
restore.

Closes #2705
@JarryShaw JarryShaw added this to the PyPCAPKit v1.6 milestone Nov 2, 2026
@JarryShaw JarryShaw added bug Issues reporting a defect (set by the bug report template; a default, not an assessment) review: good-to-go Cross-review at the current head says ready; CI state is separate labels Nov 2, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

GOOD TO GO at c5ddaf730, from a Sonnet cross-review.

  • The restore is correct: a failed fill gives back its octets-read count, KeyboardInterrupt included, and keeps the padding charge.
  • Keeping the charge is the right call: restoring both halves let 50 failed fills all pass the cap.
  • The test now covers finally: a successful fill after a failed one catches that mutant directly.

@JarryShaw
JarryShaw merged commit 9d8673f into main Nov 2, 2026
27 checks passed
@JarryShaw
JarryShaw deleted the fix/2705-ledger-restore branch November 2, 2026 23:57
@github-project-automation github-project-automation Bot moved this to Done in PyPCAPKit Nov 2, 2026
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Nov 2, 2026
JarryShaw added a commit that referenced this pull request Nov 3, 2026
… helpers, MH options 6 and 27, the cut SCTP and option-area schemas and dict-built secrets into 1.6.0 (#2449)

- Breaking: a make() enumeration field takes a member or an int, its
  X_default/X_namespace/X_reversed keywords removed with no alias, and names,
  wide codes and wide option codes are refused (#2692); the schema helpers
  move to pcapkit.corekit.schema and pcapkit.corekit.fields.byteorder is
  removed (#2704); MobileNetworkPrefixOption gains prefix_length and keeps an
  IPv6Address prefix, and TimestampOption's timestamp is None past 9999
  (#2709). Folded into the MH data-model entry; old values measured against
  v1.5.1.
- Fixed: the SCTP schema cut inside its padding and a header schema cut
  inside an option area pack back as captured (#2682), into the SCTP entry;
  a Decryption Secrets Block rebuilds from its dict as captured (#2707), into
  the DSB entry.
- Folded into unreleased entries: FRAD's Q.922 address refusal and quiet cut
  rebuild (#2719); a from_data rebuild's checksum status (#2712); a failed
  ListField fill's ledger (#2706); pad_length's path (#2704); TLS's enumeration
  fields (#2692); the make() and schema-helper rulings, into the conventions
  entry (#2692, #2704); the GraalPy shards, into the CI-legs entry (#2720).
- 1.5.0's corekit.fields.byteorder role points at corekit.schema.byteorder,
  where #2704 moved it, so the nitpicky build does not warn on it; 1.5.0's
  text unchanged.
- No entry for the test-only 72b2bd8 (#2715), or the docs-and-test-only
  0c07940 (#2718).
- CHANGELOG.md regenerated; util/changelog_md.py --check passes.
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)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

fix(corekit): a failed list zero-fill leaves its ledger debit behind

1 participant