{"record":{"id":"a4cf9e04663abea8","repo":"pola-rs/polars","slug":"invalid-map-dtype-in-series-full-null","errorCode":null,"errorMessage":"invalid Map dtype in `Series::full_null`","messagePattern":"invalid Map dtype in `Series::full_null`","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-core/src/series/ops/null.rs","lineNumber":20,"sourceCode":"use polars_arrow::offset::OffsetsBuffer;\nuse polars_buffer::Buffer;\n\n#[cfg(feature = \"object\")]\nuse crate::chunked_array::object::registry::get_object_builder;\nuse crate::prelude::*;\n\nimpl Series {\n    /// Create a Series of `size` null values with the requested dtype.\n    ///\n    /// # Panics\n    /// Panics if `dtype` contains an invalid Map dtype.\n    pub fn full_null(name: PlSmallStr, size: usize, dtype: &DataType) -> Self {\n        // Separate from the `match` below, because it only peels off a single layer of\n        // nesting.\n        #[cfg(feature = \"dtype-map\")]\n        dtype\n            .ensure_valid_map_dtypes()\n            .expect(\"invalid Map dtype in `Series::full_null`\");\n\n        // match the logical types and create them\n        match dtype {\n            DataType::List(inner_dtype) => {\n                ListChunked::full_null_with_dtype(name, size, inner_dtype).into_series()\n            },\n            #[cfg(feature = \"dtype-array\")]\n            DataType::Array(inner_dtype, width) => {\n                ArrayChunked::full_null_with_dtype(name, size, inner_dtype, *width).into_series()\n            },\n            #[cfg(feature = \"dtype-categorical\")]\n            dt @ (DataType::Categorical(_, _) | DataType::Enum(_, _)) => {\n                with_match_categorical_physical_type!(dt.cat_physical().unwrap(), |$C| {\n                    CategoricalChunked::<$C>::full_null_with_dtype(\n                        name,\n                        size,\n                        dtype.clone()\n                    )","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-core/src/series/ops/null.rs#L2-L38","documentation":"Series::full_null constructs an all-null Series of a given dtype. When the requested dtype is Map (feature `dtype-map`), it first validates the Map's inner/entry dtypes via ensure_valid_map_dtypes; if that returns Err, the code panics because full_null cannot return a Result. It means the Map dtype supplied is structurally invalid (e.g. bad inner key/value dtypes).","triggerScenarios":"Calling Series::full_null(name, size, &DataType::Map(...)) with an invalid inner dtype combination, or propagating a malformed Map dtype (e.g. from deserialization or a hand-constructed DataType) into full_null.","commonSituations":"Building empty/all-null frames with a Map column whose dtype was constructed manually or round-tripped from a source with unsupported entry types; dtype mismatches after schema stitching.","solutions":["Inspect the Map dtype's inner key/value types and construct it with valid entry dtypes (valid value types, list-of-entries structure)","Avoid hand-building DataType::Map; obtain the dtype from an existing valid Map column and reuse it","If you only need a null placeholder, use a supported dtype (e.g. List) or wrap full_null's dtype construction so invalid maps are rejected earlier","Verify the feature set: `dtype-map` is unstable; consider avoiding Map in schemas that get all-null materialized"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"fn map_dtype_is_valid(dt: &DataType) -> bool {\n    match dt {\n        DataType::Map(_, _) => true, // tighten: validate entry/value dtypes\n        _ => true,\n    }\n}\nif !map_dtype_is_valid(dtype) { return Err(\"invalid Map dtype for full_null\"); }","typeGuard":"fn is_map(dt: &DataType) -> bool { matches!(dt, DataType::Map(_, _)) }","tryCatchPattern":null,"preventionTips":["Avoid hand-constructing DataType::Map; derive it from an existing valid column","Keep Map columns out of schemas that get materialized as all-null frames","Test schema round-trips (serde/deserialization) that involve Map dtypes"],"tags":["rust","polars","dtype","map"],"backgroundTag":"invalid-argument-value","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}