{"record":{"id":"3d682e594dda5355","repo":"risingwavelabs/risingwave","slug":"expected-but-got","errorCode":null,"errorMessage":"expected {} but got {:?}","messagePattern":"expected (.+?) but got (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/connector/src/macros.rs","lineNumber":307,"sourceCode":"#[macro_export]\nmacro_rules! impl_split {\n    ({$({ $variant_name:ident, $prop_name:ty, $split:ty}),*}) => {\n\n        #[derive(Debug, Clone, EnumAsInner, PartialEq)]\n        pub enum SplitImpl {\n            $(\n                $variant_name($split),\n            )*\n        }\n\n        $(\n            impl TryFrom<SplitImpl> for $split {\n                type Error = $crate::error::ConnectorError;\n\n                fn try_from(split: SplitImpl) -> std::result::Result<Self, Self::Error> {\n                    match split {\n                        SplitImpl::$variant_name(inner) => Ok(inner),\n                        other => risingwave_common::bail!(\n                            \"expected {} but got {:?}\",\n                            stringify!($split),\n                            other\n                        ),\n                    }\n                }\n            }\n\n            impl From<$split> for SplitImpl {\n                fn from(split: $split) -> SplitImpl {\n                    SplitImpl::$variant_name(split)\n                }\n            }\n\n        )*\n    }\n}\n","sourceCodeStart":289,"sourceCodeEnd":325,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/connector/src/macros.rs#L289-L325","documentation":"A macro-generated TryFrom<SplitImpl> conversion failed: the SplitImpl enum held a different connector's split variant than the one being downcast to. risingwave_common::bail! produces 'expected <Variant> but got <actual>'. Note the eq/partial_cmp uses shown at top_n.rs are unrelated PartialEq impls; the error itself originates in the macro's try_from.","triggerScenarios":"Casting a SplitImpl to a concrete split type (e.g. SplitImpl::try_into::<KafkaSplit>()) when the split actually belongs to another connector, typically due to mixed-up sources, a scheduler bug, or misconfigured fragment/split assignment.","commonSituations":"Batch execution or recovery after a catalog change where splits persisted for one connector are replayed against another; running queries over a source whose connector type changed; internal split-routing bugs.","solutions":["Check the WITH connector type of the source/table matches the expected split type","Recreate the sink/source or restart the query so splits are regenerated for the correct connector","If seen after a version upgrade, clear stale split state (recovery/recreate) and report the mismatch"],"exampleFix":"// before\nlet s: KafkaSplit = split.try_into()?; // split is actually an IcebergSplit\n// after\nlet SplitImpl::Kafka(s) = &split else { return Err(anyhow!(\"unexpected split {:?}\", split)); };","handlingStrategy":"type-guard","validationCode":"fn expect_kafka_split(split: &SplitImpl) -> Option<&KafkaSplit> {\n    match split { SplitImpl::Kafka(s) => Some(s), _ => None }\n}","typeGuard":"fn as_variant<T: 'static>(split: &SplitImpl, f: impl Fn(&SplitImpl) -> Option<&T>) -> Option<&T> { f(split) }\n// or simply:\nfn is_kafka(split: &SplitImpl) -> bool { matches!(split, SplitImpl::Kafka(_)) }","tryCatchPattern":"let kafka_split: KafkaSplit = SplitImpl::try_from(split.clone())\n    .map_err(|e| anyhow!(\"split routing mismatch: {}\", e))?;","preventionTips":["Ensure each executor/scan only receives splits generated by its own connector","Avoid reusing persisted split metadata across connector type changes","Add assertions on split type at fragment assignment time"],"tags":["split","connector","type-mismatch","macros"],"backgroundTag":"incompatible-source-type","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}