vectordotdev/vector · error

path and query should never fail to parse

Error message

path and query should never fail to parse

What it means

The Azure Logs Ingestion sink builds the request path /dataCollectionRules/{dcr_immutable_id}/streams/{stream_name}?api-version=... and parses it as an http PathAndQuery. The expect fires when that string violates the URI grammar because the configured DCR immutable ID or stream name contains characters like spaces, non-ASCII bytes, control characters, or stray percent signs.

Source

Thrown at src/sinks/azure_logs_ingestion/service.rs:96

    token_scope: String,
    default_headers: HeaderMap,
}

impl AzureLogsIngestionService {
    /// Creates a new `AzureLogsIngestionService`.
    pub fn new(
        client: HttpClient,
        endpoint: Uri,
        dcr_immutable_id: String,
        stream_name: String,
        credential: Arc<dyn TokenCredential>,
        token_scope: String,
    ) -> crate::Result<Self> {
        let mut parts = endpoint.into_parts();
        parts.path_and_query = Some(
            format!("/dataCollectionRules/{dcr_immutable_id}/streams/{stream_name}?api-version={API_VERSION}")
                .parse()
                .expect("path and query should never fail to parse"),
        );
        let endpoint = Uri::from_parts(parts)?;

        let default_headers = {
            let mut headers = HeaderMap::new();

            headers.insert(header::CONTENT_TYPE, CONTENT_TYPE_VALUE.clone());
            headers
        };

        Ok(Self {
            client,
            endpoint,
            credential,
            token_scope,
            default_headers,
        })
    }

View on GitHub (pinned to 3708c39b12)

Solutions

  1. Set stream_name to a URI-safe value: letters, digits, '-' and '_' only (Azure convention is Custom-MyTable with no spaces)
  2. Trim whitespace/newlines when injecting values via environment variables (e.g. tr -d '[:space:]')
  3. Validate both fields at config load with regex ^[A-Za-z0-9\-_.~]+$ and fail fast with a clear error
  4. Percent-encode the stream name before it reaches the sink if special characters are unavoidable

Example fix

# before
[sinks.azure]
type = "azure_logs_ingestion"
stream_name = "Custom-My Table"

# after
[sinks.azure]
type = "azure_logs_ingestion"
stream_name = "Custom-My_Table"
Defensive patterns

Strategy: validation

Validate before calling

fn uri_safe(s: &str) -> bool {
    !s.is_empty()
        && s.bytes().all(|b| {
            b.is_ascii_alphanumeric() || matches!(b, b'-' | b'_' | b'.' | b'~')
        })
}

assert!(uri_safe(&stream_name), "stream_name must be URI-safe");
assert!(uri_safe(&dcr_immutable_id), "DCR immutable ID must be URI-safe");

Type guard

fn is_uri_safe_stream_name(s: &str) -> bool {
    !s.is_empty()
        && s.bytes().all(|b| {
            b.is_ascii_alphanumeric() || matches!(b, b'-' | b'_' | b'.' | b'~')
        })
}

Prevention

When it happens

Trigger: Configuring stream_name or dcr_immutable_id with a value such as 'Custom-My Table' (space), a Unicode name, an invalid %-escape, or a trailing newline injected via environment-variable interpolation. DCR immutable IDs are GUID-like and safe, so stream_name is the usual culprit.

Common situations: Stream names copied from the Azure Portal with spaces; values injected from env vars containing quotes or newlines; names with % characters forming invalid escapes.

Related errors


AI-assisted analysis of vectordotdev/vector@3708c39b12 (2026-08-20). Data as JSON: /api/errors/d8ad9fca5545a09d. Report an issue: GitHub.