{"record":{"id":"d4145501a6bb4eea","repo":"quickwit-oss/quickwit","slug":"object-type-must-have-at-least-one-field-mapping","errorCode":null,"errorMessage":"object type must have at least one field mapping","messagePattern":"object type must have at least one field mapping","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"quickwit/quickwit-doc-mapper/src/doc_mapper/field_mapping_entry.rs","lineNumber":731,"sourceCode":"            .set_fieldnorms(quickwit_text_options.indexing_options.fieldnorms)\n            .set_tokenizer(quickwit_text_options.indexing_options.tokenizer.name());\n\n        text_options = text_options.set_indexing_options(text_field_indexing);\n        text_options\n    }\n}\n\nfn deserialize_mapping_type(\n    quickwit_field_type: QuickwitFieldType,\n    json: JsonValue,\n) -> anyhow::Result<FieldMappingType> {\n    let (typ, cardinality) = match quickwit_field_type {\n        QuickwitFieldType::Simple(typ) => (typ, Cardinality::SingleValued),\n        QuickwitFieldType::Array(typ) => (typ, Cardinality::MultiValued),\n        QuickwitFieldType::Object => {\n            let object_options: QuickwitObjectOptions = serde_json::from_value(json)?;\n            if object_options.field_mappings.is_empty() {\n                anyhow::bail!(\"object type must have at least one field mapping\");\n            }\n            return Ok(FieldMappingType::Object(object_options));\n        }\n        QuickwitFieldType::Concatenate => {\n            let concatenate_options: QuickwitConcatenateOptions = serde_json::from_value(json)?;\n            if concatenate_options.concatenate_fields.is_empty()\n                && !concatenate_options.include_dynamic_fields\n            {\n                anyhow::bail!(\"concatenate type must have at least one sub-field\");\n            }\n            return Ok(FieldMappingType::Concatenate(concatenate_options));\n        }\n    };\n    match typ {\n        Type::Str => {\n            let text_options: QuickwitTextOptions = serde_json::from_value(json)?;\n            Ok(FieldMappingType::Text(text_options, cardinality))\n        }","sourceCodeStart":713,"sourceCodeEnd":749,"githubUrl":"https://github.com/quickwit-oss/quickwit/blob/a39730c5cdcd1a4fe798403737ae293999ea21f8/quickwit/quickwit-doc-mapper/src/doc_mapper/field_mapping_entry.rs#L713-L749","documentation":"A field of type `object` in a Quickwit mapping must declare its nested `field_mappings`. When deserializing the object options, an empty field_mappings list means the object contributes nothing to the schema, so FieldMappingType deserialization fails. This prevents empty schema branches.","triggerScenarios":"Submitting an index config with `{name: \"parent\", type: \"object\", field_mappings: []}` — serde deserialization of FieldMappingType::Object via from_json bails.","commonSituations":"Programmatic mapping generation that starts with an empty field list; hand-written mappings where nested fields were accidentally removed; templating that emits `field_mappings: []` as a placeholder.","solutions":["Add at least one field mapping inside the object's `field_mappings`.","If the object is not needed, remove the object field entirely instead of leaving it empty.","If nested fields are optional at creation, build the mapping only once you know the concrete sub-fields."],"exampleFix":"// before\n{name: \"user\", type: \"object\", field_mappings: []}\n// after\n{name: \"user\", type: \"object\", field_mappings: [{name: \"id\", type: \"u64\"}]}","handlingStrategy":"validation","validationCode":"fn object_has_children(f: &serde_json::Value) -> bool {\n    f.get(\"type\").and_then(|t| t.as_str()) != Some(\"object\")\n        || f.get(\"field_mappings\")\n            .and_then(|m| m.as_array())\n            .map_or(false, |a| !a.is_empty())\n}","typeGuard":null,"tryCatchPattern":"match create_index_result {\n    Err(e) if e.to_string().contains(\"at least one field mapping\") => {\n        eprintln!(\"Add nested field_mappings or remove the empty object field\");\n    }\n    other => other?,\n}","preventionTips":["Only emit object fields once their sub-fields are known.","Validate generated mappings programmatically before submission.","Remove placeholder object fields from templates."],"tags":["schema","mapping","validation","rust"],"backgroundTag":"empty-required-field","analyzedSha":"a39730c5cdcd1a4fe798403737ae293999ea21f8","analyzedAt":"2026-09-08T13:19:37.784Z","contentChangedAt":"2026-09-08T13:19:37.784Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}