fix(dogstatsd): reject tag_length.end() <= MIN_TAG_LENGTH upfront#1875
Open
blt wants to merge 1 commit into
Open
fix(dogstatsd): reject tag_length.end() <= MIN_TAG_LENGTH upfront#1875blt wants to merge 1 commit into
blt wants to merge 1 commit into
Conversation
The dogstatsd `common::tags::Generator` wrapper subtracts one from
`tag_length.end()` to account for the on-wire `:` separator before
forwarding to the inner generator. The inner generator requires
`start() >= MIN_TAG_LENGTH = 3`. When the caller's `tag_length.end()`
equalled `MIN_TAG_LENGTH` -- e.g. `Constant(3)` or `Inclusive { 3, 3 }` --
the wrapper produced `Inclusive { 3, 2 }` and the inner rejected it on
`min <= max`. That rejection surfaced upstream as `Error::StringGenerate`,
which dropped the underlying message and pointed callers at pool
generation rather than the config range that was actually at fault.
Validate the constraint at the wrapper entrypoint and return a dedicated
`Error::TagLengthEndTooSmall` variant naming the offending value and the
minimum required. Tests cover both the rejection cases and the smallest
accepted `end` value.
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.
Summary
The
dogstatsd::common::tags::Generatorwrapper subtracts one fromtag_length.end()to account for the on-wire:separator, then forwards the adjusted range tocommon::tags::Generator. The inner generator requiresstart() >= MIN_TAG_LENGTH = 3. When the caller'stag_length.end()equalledMIN_TAG_LENGTH-- e.g.ConfRange::Constant(3)orConfRange::Inclusive { min: 3, max: 3 }-- the wrapper producedInclusive { min: 3, max: 2 }. The inner then rejected the range onmin <= maxand the failure bubbled up asError::StringGenerate, which drops the underlying message and points callers at pool generation rather than at the tag-length range that was actually at fault.This change validates the constraint at the wrapper entrypoint and returns a dedicated
Error::TagLengthEndTooSmallvariant naming the offending value and the minimum required. The wrapper docstring is updated to record the post-adjustend > MIN_TAG_LENGTHcontract.Discovered while fuzzing
DogStatsD::newfrom an external rig: the symptom was aStringGeneratefailure at specific seeds, with no indication that the actual root cause was the configured tag-length range collapsing to its lower bound.Test plan
cargo test -p lading-payload-- 211 tests pass including three new wrapper tests (tag_length_constant_at_min_rejected,tag_length_inclusive_min_equals_max_at_min_rejected,tag_length_at_min_plus_one_accepted).cargo clippy -p lading-payload --all-targets-- clean.Unreleased.