{"record":{"id":"d544f4316f559e9e","repo":"vectordotdev/vector","slug":"invalid-map-schema-for-field-field-name-reas","errorCode":null,"errorMessage":"Invalid Map schema for field '{field_name}': {reason}","messagePattern":"Invalid Map schema for field '(.+?)': (.+?)","errorType":"validation","errorClass":"ArrowEncodingError","httpStatus":null,"severity":"error","filePath":"lib/codecs/src/encoding/format/arrow.rs","lineNumber":258,"sourceCode":"        DataType::List(inner_field) => DataType::List(make_field_nullable(inner_field)?.into()),\n        DataType::Struct(fields) => DataType::Struct(\n            fields\n                .iter()\n                .map(|f| make_field_nullable(f))\n                .collect::<Result<Vec<_>, _>>()?\n                .into(),\n        ),\n        DataType::Map(inner, sorted) => {\n            // A Map's inner field is a \"entries\" Struct<Key, Value>\n            let DataType::Struct(fields) = inner.data_type() else {\n                return InvalidMapSchemaSnafu {\n                    field_name: field.name(),\n                    reason: format!(\"inner type must be Struct, found {:?}\", inner.data_type()),\n                }\n                .fail();\n            };\n\n            ensure!(\n                fields.len() == 2,\n                InvalidMapSchemaSnafu {\n                    field_name: field.name(),\n                    reason: format!(\"expected 2 fields (key, value), found {}\", fields.len()),\n                },\n            );\n            let key_field = &fields[0];\n            let value_field = &fields[1];\n\n            let new_struct_fields: Fields =\n                [key_field.clone(), make_field_nullable(value_field)?.into()].into();\n\n            // Reconstruct the inner \"entries\" field\n            // The inner field itself must be non-nullable (only the Map wrapper is nullable)\n            let new_inner_field = inner\n                .as_ref()\n                .clone()\n                .with_data_type(DataType::Struct(new_struct_fields))","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/vectordotdev/vector/blob/3708c39b12a93212ed8b8d7510b4cc7769cb5864/lib/codecs/src/encoding/format/arrow.rs#L240-L276","documentation":"The Arrow serializer walks each schema field; for a `DataType::Map`, Arrow requires the inner type to be a Struct named \"entries\" with exactly two fields (key, value). If the inner type is not a Struct, `InvalidMapSchemaSnafu` fails with this message naming the field and the offending inner type. It is a schema-shape validation error raised while preparing the Arrow encoder, before any events are serialized.","triggerScenarios":"Building/using an Arrow schema (Vector's `encoding.codec = \"arrow\"` with a supplied schema, or the codecs API directly) where a Map field's inner type is e.g. another Map, a List, or a primitive instead of `Struct<key: K, value: V>`. A Struct inner with ≠2 fields hits the same error variant with a different reason string.","commonSituations":"Hand-writing Arrow schemas from JSON examples that model maps as `map<string, list<...>>`; converting Parquet/JSON-derived schemas that embed map-of-list types; schema drift after upgrading arrow-rs where Map inner representation changed.","solutions":["Rewrite the offending Map field so its inner type is `Struct<key: K, value: V-not-null>` (Arrow's entries convention) — e.g. `Map(Field(\"entries\", Struct[(\"key\", Utf8), (\"value\", V)]), sorted)`.","If the logical data is a nested collection rather than a map, use `DataType::List` instead of `Map`.","Validate the schema with arrow-rs `DataType::try_parse`/a small unit test before deploying it to the sink config."],"exampleFix":"// before\nDataType::Map(\n    Field::new(\"entries\", DataType::Utf8, false).into(),\n    false,\n)\n\n// after\nlet kv = DataType::Struct(Fields::from(vec![\n    Field::new(\"key\", DataType::Utf8, false),\n    Field::new(\"value\", DataType::Utf8, false),\n]));\nDataType::Map(Field::new(\"entries\", kv, false).into(), false)","handlingStrategy":"validation","validationCode":"fn assert_arrow_maps_valid(schema: &arrow_schema::Schema) -> Result<(), String> {\n    for f in schema.fields() {\n        if let DataType::Map(inner, _) = f.data_type() {\n            let DataType::Struct(fields) = inner.data_type() else {\n                return Err(format!(\"field {} Map inner must be Struct\", f.name()));\n            };\n            if fields.len() != 2 {\n                return Err(format!(\"field {} Map entries must be <key, value>\", f.name()));\n            }\n        }\n    }\n    Ok(())\n}","typeGuard":"fn is_valid_arrow_map(field: &Field) -> bool {\n    matches!(field.data_type(), DataType::Map(inner, _)\n        if matches!(inner.data_type(), DataType::Struct(fs) if fs.len() == 2))\n}","tryCatchPattern":null,"preventionTips":["Validate the schema in a unit test at build time, before it reaches the encoder config.","Generate schemas with arrow-rs helpers rather than hand-assembling Map types.","Model nested collections as List unless key→value semantics are truly needed."],"tags":["arrow","schema","encoding","validation","vector"],"backgroundTag":"arrow-schema-invalid","analyzedSha":"3708c39b12a93212ed8b8d7510b4cc7769cb5864","analyzedAt":"2026-08-20T07:02:18.786Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}