Skip to content

fix(loki sink): validate endpoint is an absolute URL#25535

Open
xfocus3 wants to merge 1 commit into
vectordotdev:masterfrom
xfocus3:fix/loki-endpoint-validation-10980
Open

fix(loki sink): validate endpoint is an absolute URL#25535
xfocus3 wants to merge 1 commit into
vectordotdev:masterfrom
xfocus3:fix/loki-endpoint-validation-10980

Conversation

@xfocus3
Copy link
Copy Markdown

@xfocus3 xfocus3 commented May 30, 2026

Summary

Closes #10980.

The loki sink's endpoint option is deserialized as a permissive UriSerde, 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 via append_path — with an opaque error:

Configuration error. error=Sink "loki": invalid format

This gives the user no indication that the problem is the endpoint value.

This PR validates the endpoint when the sink is built (alongside the existing label validation) and returns a clear, actionable error instead.

Before

[sinks.loki]
type = "loki"
inputs = ["in"]
labels.host = "localhost"
endpoint = "something-with-a-typo-that-is-hard-to-notice"
encoding.codec = "logfmt"
Configuration error. error=Sink "loki": invalid format

After

Configuration error. error=Sink "loki": Invalid `endpoint`: ... is not an absolute URL. Expected a value with a scheme and host, such as "http://localhost:3100".

How did you test this PR?

  • cargo check --lib --no-default-features --features sinks-loki — passes
  • cargo test --lib --no-default-features --features sinks-loki loki::config — passes (added validates_endpoint unit test; existing valid_label_names still passes)
  • cargo fmt --check — passes
  • cargo clippy --lib --no-default-features --features sinks-loki -- -D warnings — passes

The fix matches the direction suggested by @jszwedko in the issue thread (checking for the needed URL parts at the configuration layer).

Change Type

  • Bug fix
  • New feature
  • Dependencies
  • Non-functional (chore, refactoring, docs)
  • Performance

Is this a breaking change?

  • Yes
  • No

A configuration with a scheme-less endpoint already 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?

  • Yes. Please add a changelog fragment based on our guidelines.
  • No. A maintainer will apply the no-changelog label to this PR.

References

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
@xfocus3 xfocus3 requested a review from a team as a code owner May 30, 2026 11:56
@github-actions github-actions Bot added the domain: sinks Anything related to the Vector's sinks label May 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: sinks Anything related to the Vector's sinks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Configuration error. error=Sink "loki": invalid format

1 participant