Skip to content

fix(point): preserve progress when trimming protobuf batches - #215

Merged
coanor merged 1 commit into
mainfrom
fix/point-encoder-trim-progress
Oct 29, 2026
Merged

coanor merged 1 commit into
mainfrom
fix/point-encoder-trim-progress

Conversation

@leecha

@leecha leecha commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator

Protobuf size estimation can admit a batch that exponential trimming removes completely, rewinding the input index and making the retry loop from #213 run forever. Trimming can also exceed the remaining slice length and panic.

Cap each trim at the number of remaining points minus one, and update the input index and counters by the actual number removed. This leaves one candidate for the existing encode-or-skip decision, guaranteeing progress without changing strict-error or oversized-point handling.

Regression coverage includes a 1 MiB batch of three individually encodable points, precise-size protobuf envelope overhead, exact/excessive trimming, and an oversized point followed by tiny points. Both ignore and strict modes check decoded bytes, ordering, counters and callbacks. A direct progress check fails before calling Next if the original infinite-loop regression returns.

Validation on Linux arm64, Go 1.26.10, CGO enabled:

  • Confirmed the new regression tests fail against main before the fix.
  • Targeted encoder tests and the new regression cases passed with -race.
  • make test passed with GOFLAGS limiting execution to TestV2Encode., TestEncTrim, TestEncNilPoint, TestSkipLargePoint and TestParseResourceSpans.; this also compiled all packages. The unfiltered full test suite was not rerun.
  • Diff-scoped golangci-lint reported 0 issues; both changed files passed copyright checks; git diff --check passed.
  • Full make lint and copyright_check still report the same pre-existing 67 lint findings and 73 header violations.
  • Independent standards and specification reviews found no new blocking issues.

@coanor
coanor merged commit 65215f8 into main Oct 29, 2026
1 check passed
@coanor
coanor deleted the fix/point-encoder-trim-progress branch October 29, 2026 10:33
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