{"record":{"id":"a2c8fcaec31d1fa4","repo":"vectordotdev/vector","slug":"password-must-be-valid-utf-8","errorCode":null,"errorMessage":"Password must be valid UTF-8.","messagePattern":"Password must be valid UTF-8\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/vector-core/src/config/proxy.rs","lineNumber":171,"sourceCode":"    }\n\n    fn build_proxy(\n        &self,\n        proxy_scheme: &'static str,\n        proxy_url: Option<&String>,\n    ) -> Result<Option<Proxy>, InvalidUri> {\n        proxy_url\n            .as_ref()\n            .map(|url| {\n                url.parse().map(|parsed| {\n                    let mut proxy = Proxy::new(self.interceptor().intercept(proxy_scheme), parsed);\n                    if let Ok(authority) = Url::parse(url)\n                        && let Some(password) = authority.password()\n                    {\n                        let decoded_user = urlencoding::decode(authority.username())\n                            .expect(\"username must be valid UTF-8.\");\n                        let decoded_pw =\n                            urlencoding::decode(password).expect(\"Password must be valid UTF-8.\");\n                        let mut authorization =\n                            Authorization::basic(&decoded_user, &decoded_pw).0.encode();\n                        authorization.set_sensitive(true);\n                        proxy.set_header(PROXY_AUTHORIZATION, authorization);\n                    }\n                    proxy\n                })\n            })\n            .transpose()\n    }\n\n    fn http_proxy(&self) -> Result<Option<Proxy>, InvalidUri> {\n        self.build_proxy(\"http\", self.http.as_ref())\n    }\n\n    fn https_proxy(&self) -> Result<Option<Proxy>, InvalidUri> {\n        self.build_proxy(\"https\", self.https.as_ref())\n    }","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/lib/vector-core/src/config/proxy.rs#L153-L189","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Correctly percent-encode the password in the proxy URL: replace each literal '%' with '%25' and encode other special characters.","Encode the secret programmatically: urlencoding::encode(&password) when composing the URL.","If the secret system guarantees raw characters, place credentials via a mechanism that doesn't require URL encoding, or update the proxy URL entirely.","Test the proxy URL by parsing it with Url::parse and checking authority.password() decodes cleanly before deploying."],"exampleFix":"// before\nproxy_url = \"http://svc:p%ssword@proxy.corp:3128\"  // invalid %ss escape\n// after\nproxy_url = format!(\"http://svc:{}@proxy.corp:3128\", urlencoding::encode(\"p%ssword\"));","handlingStrategy":"validation","validationCode":"fn validate_proxy_password(proxy_url: &str) -> Result<(), String> {\n    let url = Url::parse(proxy_url).map_err(|e| e.to_string())?;\n    match url.password() {\n        Some(pw) => urlencoding::decode(pw)\n            .map(|_| ())\n            .map_err(|_| format!(\"invalid percent-encoding in proxy password: {proxy_url}\")),\n        None => Ok(()),\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Percent-encode passwords programmatically (urlencoding::encode) rather than by hand.","Escape every literal '%' in secrets as '%25' when embedding them in URLs.","Run a decode sanity check on proxy credentials in CI before shipping configs.","Source secrets from env/template fields and encode at URL-composition time."],"tags":["proxy","url","encoding","utf-8","panic","credentials"],"backgroundTag":"invalid-url-format","analyzedSha":"bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013","analyzedAt":"2026-09-16T02:53:35.741Z","contentChangedAt":"2026-09-16T02:53:35.741Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}