{"record":{"id":"fcb6987ff87cbe59","repo":"vectordotdev/vector","slug":"called-transform-into-task-on-something-that-was-not-a-task","errorCode":null,"errorMessage":"Called `Transform::into_task` on something that was not a task variant.","messagePattern":"Called `Transform::into_task` on something that was not a task variant\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/vector-core/src/transform/mod.rs","lineNumber":84,"sourceCode":"    /// where possible.\n    ///\n    /// # Panics\n    ///\n    /// TODO\n    pub fn event_task(v: impl TaskTransform<Event> + 'static) -> Self {\n        Transform::Task(Box::new(WrapEventTask(v)))\n    }\n\n    /// Transmute the inner transform into a task transform.\n    ///\n    /// # Panics\n    ///\n    /// If the transform is a [`FunctionTransform`] this will panic.\n    pub fn into_task(self) -> Box<dyn TaskTransform<EventArray>> {\n        match self {\n            Transform::Task(t) => t,\n            _ => {\n                panic!(\"Called `Transform::into_task` on something that was not a task variant.\")\n            }\n        }\n    }\n}\n\n/// Transforms that are simple, and don't require attention to coordination.\n/// You can run them as simple functions over events in any order.\n///\n/// # Invariants\n///\n/// * It is an illegal invariant to implement `FunctionTransform` for a\n///   `TaskTransform` or vice versa.\npub trait FunctionTransform: Send + dyn_clone::DynClone + Sync {\n    fn transform(&mut self, output: &mut OutputBuffer, event: Event);\n}\n\ndyn_clone::clone_trait_object!(FunctionTransform);\n","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/lib/vector-core/src/transform/mod.rs#L66-L102","documentation":"Transform::into_task converts an enum-wrapped transform into its boxed TaskTransform variant. Because the enum also holds non-task variants (e.g. FunctionTransform), the method can only be called on the Task variant; any other variant hits an explicit panic, since a function transform has no task representation.","triggerScenarios":"Calling into_task() on a Transform constructed from a function-style transform (one implementing FunctionTransform) or from any non-Task variant instead of a task-style transform.","commonSituations":"Config/topology builders that generically iterate over transforms from configuration and assume all are task transforms; refactors where a transform was changed from task-style to function-style but call sites were not updated.","solutions":["Check which variant the Transform holds before calling into_task (add a Transform::is_task_style()/matches! check)","Use the appropriate accessor for function transforms instead of into_task","Update the construction site so the transform is built as Transform::Task"],"exampleFix":"// before\nlet task = transform.into_task();\n// after\nassert!(transform.is_task_style(), \"transform {:?} is not a task transform\", transform);\nlet task = transform.into_task();","handlingStrategy":"type-guard","validationCode":"if !transform.is_task_style() {\n    return Err(anyhow!(\"transform is not task-style; cannot call into_task\"));\n}","typeGuard":"fn is_task(t: &Transform) -> bool { matches!(t, Transform::Task(_)) }","tryCatchPattern":null,"preventionTips":["Always check is_task_style() before calling into_task or as_function","Keep transform-style metadata alongside config when building topology graphs","Add unit tests covering both task and function transforms through shared builder code"],"tags":["rust","panic","transform","internal-invariant-violation"],"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"}