vectordotdev/vector · error

Password must be valid UTF-8.

Error message

Password must be valid UTF-8.

What it means

Same mechanism as the username panic: while attaching proxy basic-auth headers, the password is percent-decoded with urlencoding::decode and unwrapped with expect. A password containing malformed percent-escape sequences causes the decode to return Err and the process panics.

Solutions

  1. Correctly percent-encode the password in the proxy URL: replace each literal '%' with '%25' and encode other special characters.
  2. Encode the secret programmatically: urlencoding::encode(&password) when composing the URL.
  3. If the secret system guarantees raw characters, place credentials via a mechanism that doesn't require URL encoding, or update the proxy URL entirely.
  4. Test the proxy URL by parsing it with Url::parse and checking authority.password() decodes cleanly before deploying.

Example fix

// before
proxy_url = "http://svc:p%ssword@proxy.corp:3128"  // invalid %ss escape
// after
proxy_url = format!("http://svc:{}@proxy.corp:3128", urlencoding::encode("p%ssword"));
Defensive patterns

Strategy: validation

Validate before calling

fn validate_proxy_password(proxy_url: &str) -> Result<(), String> {
    let url = Url::parse(proxy_url).map_err(|e| e.to_string())?;
    match url.password() {
        Some(pw) => urlencoding::decode(pw)
            .map(|_| ())
            .map_err(|_| format!("invalid percent-encoding in proxy password: {proxy_url}")),
        None => Ok(()),
    }
}

Prevention

When it happens

Trigger: Configuring proxy.http/https (or the corresponding env vars) with a URL whose password portion contains invalid percent-encoding, e.g. http://user:p%w@proxy.example.com:8080.

Common situations: Passwords containing literal '%' characters that were not doubled to '%25'; passwords copied from vendors with partial encoding; secrets injected via env vars or templates losing/mangling escapes.

Understand the failure class

Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.

Related errors


AI-assisted analysis of vectordotdev/vector@bdb87aeaa4 (2026-09-16). Data as JSON: /api/errors/a2c8fcaec31d1fa4. Report an issue: GitHub.

Appendix: source

Thrown at lib/vector-core/src/config/proxy.rs:171

    }

    fn build_proxy(
        &self,
        proxy_scheme: &'static str,
        proxy_url: Option<&String>,
    ) -> Result<Option<Proxy>, InvalidUri> {
        proxy_url
            .as_ref()
            .map(|url| {
                url.parse().map(|parsed| {
                    let mut proxy = Proxy::new(self.interceptor().intercept(proxy_scheme), parsed);
                    if let Ok(authority) = Url::parse(url)
                        && let Some(password) = authority.password()
                    {
                        let decoded_user = urlencoding::decode(authority.username())
                            .expect("username must be valid UTF-8.");
                        let decoded_pw =
                            urlencoding::decode(password).expect("Password must be valid UTF-8.");
                        let mut authorization =
                            Authorization::basic(&decoded_user, &decoded_pw).0.encode();
                        authorization.set_sensitive(true);
                        proxy.set_header(PROXY_AUTHORIZATION, authorization);
                    }
                    proxy
                })
            })
            .transpose()
    }

    fn http_proxy(&self) -> Result<Option<Proxy>, InvalidUri> {
        self.build_proxy("http", self.http.as_ref())
    }

    fn https_proxy(&self) -> Result<Option<Proxy>, InvalidUri> {
        self.build_proxy("https", self.https.as_ref())
    }

View on GitHub (pinned to bdb87aeaa4)