Repository navigation
Conversation
Validate duplicate bounds and quantiles for both text and protobuf decoders, and reject invalid families during bulk sample extraction. Keep validation scoped to individual metrics and preserve valid data. Add regression tests for both encodings and sample extraction. Fixes prometheus#51 Signed-off-by: leii2008 <ubun426406@outlook.com>
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.
When a histogram contains two buckets with the same upper bound, or a summary contains the same quantile twice, the expfmt decoders currently accept the input and SampleDecoder produces duplicate samples. This affects both Prometheus text and delimited protobuf input.
This change rejects duplicate bounds and quantiles within each metric when decoding either format. ExtractSamples also rejects invalid families while continuing to extract samples from the remaining valid families. Checks are scoped to each metric, so different label sets can still share the same bounds, and valid input is not reordered.
Fixes #51.
Validation:
Tests cover finite and infinite duplicate bounds, signed zero, gauge histograms, duplicate quantiles, unsorted distinct bounds, separate label sets, empty quantile lists, sample extraction, and reaching EOF after rejecting a family.
The change deliberately leaves the low-level TextParser API unchanged; validation happens at the Decoder and ExtractSamples boundaries. Reviewers may prefer validation in TextParser as a follow-up.
AI assistance was used to implement this change, write regression tests, and prepare this description. The test results above were obtained by running the commands against the checkout.
@roidelapluie @gotjosh