{"record":{"id":"5d394ef19240925c","repo":"vectordotdev/vector","slug":"a-validated-http-endpoint-is-a-valid-http-1-uri","errorCode":null,"errorMessage":"a validated HTTP endpoint is a valid `http 1` URI","messagePattern":"a validated HTTP endpoint is a valid `http 1` URI","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/sinks/util/uri.rs","lineNumber":405,"sourceCode":"    }\n\n    /// Consumes the endpoint, returning the underlying `Uri`.\n    pub fn into_uri(self) -> Uri {\n        self.0\n    }\n\n    /// Consumes the endpoint, returning the underlying `Uri` as an `http 1` `Uri`.\n    ///\n    /// The two `http` crate versions share no conversion traits, so the bridge\n    /// is a string round-trip. `Display` of a validated absolute `http(s)` URL\n    /// is always parseable back by `http 1` (the `http 1` parser descends from\n    /// the `http 0.2` parser and accepts the same absolute forms), so this\n    /// cannot fail — the same invariant `protocol_endpoint` relies on.\n    pub fn into_v1(self) -> http_1::Uri {\n        self.0\n            .to_string()\n            .parse()\n            .expect(\"a validated HTTP endpoint is a valid `http 1` URI\")\n    }\n\n    /// Extracts basic-auth credentials embedded in the authority, returning a\n    /// credential-free endpoint alongside the credentials.\n    pub fn extract_basic_auth(self) -> crate::Result<(Self, Option<Auth>)> {\n        if !self\n            .as_uri()\n            .authority()\n            .is_some_and(|authority| authority.as_str().contains('@'))\n        {\n            return Ok((self, None));\n        }\n\n        let UriSerde { uri, auth } = self.into_uri().try_into()?;\n        Ok((Self::new(uri)?, auth))\n    }\n\n    /// Returns the URL scheme (`http` or `https`) of this endpoint.","sourceCodeStart":387,"sourceCodeEnd":423,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/src/sinks/util/uri.rs#L387-L423","documentation":"into_v1 converts a validated HTTP/0.2-style endpoint (hyper Uri) into an http 1.x Uri by parsing its string form. The expect documents the invariant: an endpoint accepted by the protocol_endpoint validation parses cleanly under both URI grammars, so failure indicates the validation invariant was violated (or the endpoint was constructed without validation).","triggerScenarios":"Calling into_v1 on an Endpoint that was never passed through protocol_endpoint validation, or whose string form is no longer a valid http 1 URI (e.g. forged/modified internal state) — hit from the healthcheck path.","commonSituations":"Custom or newly added sink code constructing Endpoint values directly rather than via the validating constructor; a change in the http crate introducing stricter v1 URI parsing.","solutions":["Always create the Endpoint via protocol_endpoint (the validating constructor) instead of building it manually.","Verify the configured address is a normal http/https URL with host (no exotic forms) before building the sink.","If a legitimate URI fails, replace the expect with a config-time error and report the endpoint string."],"exampleFix":"// before\nself.0.to_string().parse().expect(\"a validated HTTP endpoint is a valid `http 1` URI\")\n// after\nself.0\n    .to_string()\n    .parse()\n    .map_err(|e| crate::Error::from(format!(\"endpoint {:?} is not a valid http 1 URI: {}\", self.0, e)))?","handlingStrategy":"validation","validationCode":"// build endpoints only through the validating constructor\nlet endpoint = protocol_endpoint(scheme, &address)?;","typeGuard":null,"tryCatchPattern":"self.0.to_string().parse::<http_1::Uri>().map_err(|e| crate::Error::from(...))?","preventionTips":["Never construct Endpoint values manually; always use protocol_endpoint.","Keep endpoint validation tests covering both http 0.2 and http 1 parsers.","Surface parse failures as config errors during sink build."],"tags":["rust","panic","uri","http","invariant"],"backgroundTag":"internal-invariant-violation","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"}