{"record":{"id":"b3447693011461c2","repo":"vectordotdev/vector","slug":"failed-type-coercion-self-is-not-a-stream","errorCode":null,"errorMessage":"Failed type coercion, {self:?} is not a Stream","messagePattern":"Failed type coercion, (.+?) is not a Stream","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/vector-core/src/sink.rs","lineNumber":61,"sourceCode":"    /// # Panics\n    ///\n    /// This function will panic if the self instance is not `VectorSink::Sink`.\n    pub fn into_sink(self) -> Box<dyn Sink<EventArray, Error = ()> + Send + Unpin> {\n        match self {\n            Self::Sink(sink) => sink,\n            _ => panic!(\"Failed type coercion, {self:?} is not a Sink\"),\n        }\n    }\n\n    /// Converts `VectorSink` into a `StreamSink`\n    ///\n    /// # Panics\n    ///\n    /// This function will panic if the self instance is not `VectorSink::Stream`.\n    pub fn into_stream(self) -> Box<dyn StreamSink<EventArray> + Send> {\n        match self {\n            Self::Stream(stream) => stream,\n            _ => panic!(\"Failed type coercion, {self:?} is not a Stream\"),\n        }\n    }\n\n    /// Converts an event sink into a `VectorSink`\n    ///\n    /// Deprecated in favor of `VectorSink::from_event_streamsink`. See [vector/9261]\n    /// for more info.\n    ///\n    /// [vector/9261]: https://github.com/vectordotdev/vector/issues/9261\n    #[deprecated]\n    pub fn from_event_sink(sink: impl Sink<Event, Error = ()> + Send + Unpin + 'static) -> Self {\n        VectorSink::Sink(Box::new(EventSink::new(sink)))\n    }\n\n    /// Converts an event stream into a `VectorSink`\n    pub fn from_event_streamsink(sink: impl StreamSink<Event> + Send + 'static) -> Self {\n        let sink = Box::new(sink);\n        VectorSink::Stream(Box::new(EventStream { sink }))","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/lib/vector-core/src/sink.rs#L43-L79","documentation":"VectorSink::into_stream unwraps the VectorSink enum into its Stream variant (a Box<dyn StreamSink<EventArray>>), panicking if the sink was built as the legacy Sink variant. The caller asserted the component produces a stream-style sink; the panic fires when it does not.","triggerScenarios":"Calling VectorSink::into_stream on a sink built via the deprecated VectorSink::from_event_sink (the Sink variant), or on any component that still returns an event sink.","commonSituations":"Custom integrations/test harnesses written against stream sinks, run with a component or fixture built with the deprecated from_event_sink constructor.","solutions":["Match on VectorSink and only call into_stream for VectorSink::Stream","Prefer VectorSink::run / run_events which dispatch correctly for both variants","Replace uses of the deprecated VectorSink::from_event_sink with VectorSink::from_event_streamsink so the Stream variant is guaranteed"],"exampleFix":"// before\nlet stream = vector_sink.into_stream();\n// after\nmatch vector_sink {\n    VectorSink::Stream(s) => /* use s */,\n    VectorSink::Sink(_) => panic!(\"expected stream sink\"),\n}\n// or generically:\nvector_sink.run(input).await?;","handlingStrategy":"type-guard","validationCode":"assert!(matches!(vector_sink, VectorSink::Stream(_)), \"expected stream sink, got {:?}\", vector_sink);","typeGuard":"fn as_stream_sink(s: VectorSink) -> Option<Box<dyn StreamSink<EventArray> + Send>> {\n    match s {\n        VectorSink::Stream(stream) => Some(stream),\n        _ => None,\n    }\n}","tryCatchPattern":null,"preventionTips":["Avoid the deprecated VectorSink::from_event_sink; use from_event_streamsink","Use VectorSink::run/run_events which handle both variants","Match on the VectorSink enum in custom drivers before unwrapping"],"tags":["rust","panic","sink","type-coercion"],"backgroundTag":"type-mismatch","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"}