fix(loki sink): validate endpoint is an absolute URL#25535
Open
xfocus3 wants to merge 1 commit into
Open
Conversation
The `endpoint` option is deserialized as a permissive `UriSerde`, so a value without a scheme (such as a host name with a typo) was accepted at config parse time but later failed with an opaque `invalid format` error when the request URI was built. Validate the endpoint when building the sink and return a clear, actionable error naming the offending value and the expected form. Closes vectordotdev#10980
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
Closes #10980.
The
lokisink'sendpointoption is deserialized as a permissiveUriSerde, which accepts incomplete URIs. A value with a missing or mistyped scheme (for example a bare host name) is accepted at configuration parse time, but then fails later — when the request URI is assembled viaappend_path— with an opaque error:This gives the user no indication that the problem is the
endpointvalue.This PR validates the endpoint when the sink is built (alongside the existing label validation) and returns a clear, actionable error instead.
Before
After
How did you test this PR?
cargo check --lib --no-default-features --features sinks-loki— passescargo test --lib --no-default-features --features sinks-loki loki::config— passes (addedvalidates_endpointunit test; existingvalid_label_namesstill passes)cargo fmt --check— passescargo clippy --lib --no-default-features --features sinks-loki -- -D warnings— passesThe fix matches the direction suggested by @jszwedko in the issue thread (checking for the needed URL parts at the configuration layer).
Change Type
Is this a breaking change?
A configuration with a scheme-less
endpointalready failed to start (with an unclear error); it now fails with a clear one. Valid absolute-URL endpoints are unaffected.Does this PR include user facing changes?
no-changeloglabel to this PR.References