fix(traces): avoid panic on empty /v0.6/stats payload#1290
Open
lucaspimentel wants to merge 2 commits into
Open
fix(traces): avoid panic on empty /v0.6/stats payload#1290lucaspimentel wants to merge 2 commits into
/v0.6/stats payload#1290lucaspimentel wants to merge 2 commits into
Conversation
An empty msgpack map request body deserializes to a stats payload with no buckets, so indexing stats[0] to stamp the start time panicked with "index out of bounds". Guard the empty case and return 202 Accepted as a no-op instead. Adds a regression test. 🤖
|
/v0.6/stats payload
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a crash in the trace stats ingestion path (/v0.6/stats) by handling the edge case where the decoded ClientStatsPayload contains zero stats buckets, preventing an out-of-bounds panic in the Lambda extension’s traces subsystem.
Changes:
- Guard against empty
stats.statsand treat empty payloads as a harmless no-op returning202 Accepted. - Replace direct indexing (
stats.stats[0]) withfirst_mut()to safely access the first bucket when present. - Add a regression test ensuring an empty msgpack map body does not panic and does not enqueue anything to the aggregator channel.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
The
/v0.6/statshandler unconditionally indexedstats.stats[0]to stamp the payload start time. When the request body is an empty msgpack map (0x80),stats_utils::get_stats_from_request_bodyreturns aClientStatsPayloadwith an emptystatsvec, sostats.stats[0]panicked:This is a pre-existing bug reproducible in the Lambda binary; it surfaced while smoke-testing the test-mode binary.
The fix guards the empty case before indexing: an empty payload has nothing to buffer, so we return
202 Acceptedas a harmless no-op. When at least one bucket exists, we set.startviastats.first_mut().Testing
Added a regression test (
empty_stats_payload_does_not_panic) that feeds an empty msgpack map body and asserts the handler returns202 Acceptedwithout panicking and buffers nothing to the aggregator.🤖