{"record":{"id":"c7a3e5fa2c2d0c42","repo":"pola-rs/polars","slug":"should-not-fail","errorCode":null,"errorMessage":"should not fail","messagePattern":"should not fail","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-core/src/frame/mod.rs","lineNumber":688,"sourceCode":"        Ok(self)\n    }\n\n    /// Concatenate a [`DataFrame`] to this [`DataFrame`]\n    ///\n    /// If many `vstack` operations are done, it is recommended to call [`DataFrame::align_chunks_par`].\n    ///\n    /// # Panics\n    /// Panics if the schema's don't match.\n    pub fn vstack_mut_unchecked(&mut self, other: &DataFrame) -> &mut Self {\n        let new_height = usize::checked_add(self.height(), other.height()).unwrap();\n\n        unsafe { self.columns_mut_retain_schema() }\n            .iter_mut()\n            .zip(other.columns())\n            .for_each(|(left, right)| {\n                left.append(right)\n                    .with_context(|| format!(\"failed to vstack column '{}'\", right.name()))\n                    .expect(\"should not fail\");\n            });\n\n        unsafe { self.set_height(new_height) };\n\n        self\n    }\n\n    /// Concatenate a [`DataFrame`] to this [`DataFrame`]\n    ///\n    /// If many `vstack` operations are done, it is recommended to call [`DataFrame::align_chunks_par`].\n    ///\n    /// # Panics\n    /// Panics if the schema's don't match.\n    pub fn vstack_mut_owned_unchecked(&mut self, other: DataFrame) -> &mut Self {\n        let new_height = usize::checked_add(self.height(), other.height()).unwrap();\n\n        unsafe { self.columns_mut_retain_schema() }\n            .iter_mut()","sourceCodeStart":670,"sourceCodeEnd":706,"githubUrl":"https://github.com/pola-rs/polars/blob/68506541d2de983056c9eb244e1ea05fab377dfc/crates/polars-core/src/frame/mod.rs#L670-L706","documentation":"vstack_mut_unchecked appends each column of other to self without schema validation, trusting the caller. Series::append can still fail (mismatched dtypes, memory errors); the with_context(...).expect(\"should not fail\") converts that error into a panic naming the failing column.","triggerScenarios":"Calling DataFrame::vstack_mut_unchecked (or a caller of it) where left/right column dtypes differ for a column name, e.g. Int32 vs Int64, String vs Categorical, different time zones; or when append hits an allocation failure.","commonSituations":"Performance-tuned code skipping the checked vstack after schemas drifted (a cast added upstream, a CSV re-inferred different integer widths); concatenating frames produced by different readers or polars versions.","solutions":["Switch to the checked API: df.vstack(&other)? which returns a PolarsResult instead of panicking","Verify schemas before the unchecked call: self.schema() and other.schema() must have identical dtypes per column","Cast mismatching columns to the target dtype before vstacking"],"exampleFix":"// before\ndf.vstack_mut_unchecked(&other); // panics on dtype drift\n\n// after\ndf.vstack(&other).map_err(|e| format!(\"vstack failed: {e}\"))?;","handlingStrategy":"validation","validationCode":"fn schemas_match(a: &DataFrame, b: &DataFrame) -> bool {\n    a.schema() == b.schema()\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer the checked vstack/concat APIs; reserve unchecked variants for hot loops with a schema assertion","Assert schema equality (names, order, dtypes) immediately before unchecked vstack","Normalize dtypes against a reference schema after reading heterogeneous sources"],"tags":["rust","polars","vstack","schema-mismatch","panic","unchecked-api"],"backgroundTag":"schema-mismatch-on-concat","analyzedSha":"68506541d2de983056c9eb244e1ea05fab377dfc","analyzedAt":"2026-08-19T12:15:06.350Z","contentChangedAt":"2026-08-19T12:15:06.350Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}