Skip to content

fix(test): clarify not_reached subtest intent and strengthen assertion#30

Closed
Copilot wants to merge 3 commits into
reduce-allocationsfrom
copilot/sub-pr-22-48107fae-67ed-4e5d-a8ec-71e311bcb89e
Closed

fix(test): clarify not_reached subtest intent and strengthen assertion#30
Copilot wants to merge 3 commits into
reduce-allocationsfrom
copilot/sub-pr-22-48107fae-67ed-4e5d-a8ec-71e311bcb89e

Conversation

Copilot AI commented Mar 11, 2026

Copy link
Copy Markdown

The not_reached subtest had a misleading comment implying decode should succeed, and only checked len(result) != 0 — neither accurately reflected the test's purpose.

Changes

  • Comment: Clarifies that the payload is intentionally malformed (oversized header); the decoder hits end-of-input before exhausting the budget, so a non-ErrOutputBytesExceeded error is expected and correct.
  • Assertion: Replaces the weak len(result) == 0 check with an explicit errors.Is(err, ErrOutputBytesExceeded) assertion that directly validates the budget is not the cause of failure.
if errors.Is(err, ErrOutputBytesExceeded) {
    t.Errorf("expected budget not to be exceeded, got %v", err)
}

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

tamirms and others added 2 commits March 11, 2026 12:53
… limits

Add a MaxOutputBytes field to DecodeOptions that tracks cumulative
decoded output size across a single decode operation. Before each
allocation (array element, union arm, optional field, opaque data),
the size is added to a running total; if it exceeds MaxOutputBytes
the decode is aborted with ErrOutputBytesExceeded.

Key changes:
- Add TrackOutputBytes method and TrackOutputBytesOf[T] generic helper
- Cap array pre-allocation at 256 elements, growing via append beyond that
- Track allocations in DecodeFixedOpaque, decodeArray, decodeUnion,
  decodeMap, and allocPtrIfNil
- Bump minimum Go version to 1.25 for generics support

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ot returned

Co-authored-by: tamirms <1445829+tamirms@users.noreply.github.com>
@tamirms tamirms force-pushed the reduce-allocations branch from 112f917 to c677e1b Compare March 11, 2026 18:52
Copilot AI changed the title [WIP] Address feedback on MaxOutputBytes decode option implementation fix(test): clarify not_reached subtest intent and strengthen assertion Mar 11, 2026
@tamirms

tamirms commented Mar 11, 2026

Copy link
Copy Markdown

Closing — improvements from this PR have been incorporated into #22 where applicable. Thank you!

@tamirms tamirms closed this Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants