Repository navigation
fix: prevent index out of range panic in Datadog and Prometheus providers - #1982
Open
okarin1511 wants to merge 1 commit into
Open
okarin1511 wants to merge 1 commit into
okarin1511 wants to merge 1 commit into
Conversation
…ders The Datadog provider checks len(vs) < 1 but accesses vs[1], which panics when the pointlist pair contains only a timestamp without a value. Fix by checking len(vs) < 2. The Prometheus provider accesses v.Value[1] without a bounds check, which panics if the API returns a malformed value array with fewer than two elements. Fix by skipping results with insufficient elements. Signed-off-by: Aseem Khandekar <69676297+okarin1511@users.noreply.github.com>
This branch has not been deployed
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.
Fixes #1981
Summary
RunQuerycheckslen(vs) < 1but accessesvs[1]. Changed tolen(vs) < 2so a pointlist pair with only a timestamp (no value) returnsErrNoValuesFoundinstead of panicking.RunQueryaccessesv.Value[1]without a bounds check. Addedlen(v.Value) < 2guard that skips malformed results, letting the existingErrNoValuesFoundpath handle it.Test plan
single_element_pointlist_pairfor Datadog — verifies a pointlist entry with one element returnsErrNoValuesFoundinstead of panickingmalformed_value_arrayfor Prometheus — verifies an empty value array returnsErrNoValuesFoundinstead of panicking