{"record":{"id":"c79fa76405c0fcb1","repo":"vectordotdev/vector","slug":"username-must-be-valid-utf-8","errorCode":null,"errorMessage":"username must be valid UTF-8.","messagePattern":"username must be valid UTF-8\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/vector-core/src/config/proxy.rs","lineNumber":169,"sourceCode":"            no_proxy,\n        }\n    }\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> {","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/lib/vector-core/src/config/proxy.rs#L151-L187","documentation":"When building an HTTP(S) proxy from a proxy URL that contains basic-auth credentials, the username is percent-decoded with urlencoding::decode and unwrapped with expect. urlencoding::decode only fails on invalid percent-encoding, so this panic means the proxy URL's username contains malformed percent escape sequences (e.g. '%ZZ' or a dangling '%').","triggerScenarios":"Setting proxy.http or proxy.https (or HTTP_PROXY/HTTPS_PROXY env vars read into the proxy config) to a URL whose userinfo username has invalid percent-encoding, e.g. http://%zz:pw@proxy.example.com:8080.","commonSituations":"Users pasting proxy URLs with credentials where special characters were hand-escaped incorrectly; env vars set in CI/containers with a stray '%' in the username; copying URLs with already-decoded special characters.","solutions":["Fix the proxy URL's username: percent-encode special characters correctly (e.g. '@' -> %40, ':' -> %3A) or remove them.","Percent-encode the username programmatically (urlencoding::encode) instead of hand-crafting the URL.","Use Vector's proxy.* config to supply credentials only when needed; ensure no stray '%' characters remain.","Validate the proxy URL with Url::parse and inspect authority.username() before configuring."],"exampleFix":"// before\nexport HTTPS_PROXY=\"http://user%name:pw@proxy.corp:3128\"  // invalid %na escape\n// after\nexport HTTPS_PROXY=\"http://user%25name:pw@proxy.corp:3128\"","handlingStrategy":"validation","validationCode":"fn validate_proxy_user(proxy_url: &str) -> Result<(), String> {\n    let url = Url::parse(proxy_url).map_err(|e| e.to_string())?;\n    urlencoding::decode(url.username())\n        .map(|_| ())\n        .map_err(|_| format!(\"invalid percent-encoding in proxy username: {proxy_url}\"))\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always percent-encode userinfo with urlencoding::encode when building proxy URLs.","Replace every literal '%' in usernames with '%25' in env vars and configs.","Validate proxy URLs with Url::parse plus a decode check before deployment.","Keep credentials in dedicated config fields rather than embedding them in URLs."],"tags":["proxy","url","encoding","utf-8","panic"],"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"}