quickwit-oss/quickwit · error
duplicated field definition `{}`
Error message
duplicated field definition `{}` What it means
While building the mapping tree from the field mapping entries, two entries resolved to the same field path (e.g. an explicit field colliding with a property defined via an object/JSON subtree). The schema builder cannot hold two definitions for one field, so the duplicate is rejected with its full name.
Source
Thrown at quickwit/quickwit-doc-mapper/src/doc_mapper/mapping_tree.rs:1031
let mut field_path = Vec::new();
build_mapping_tree_from_entries(entries, &mut field_path, schema)
}
fn build_mapping_tree_from_entries<'a>(
entries: &'a [FieldMappingEntry],
field_path: &mut Vec<&'a str>,
schema: &mut SchemaBuilder,
) -> anyhow::Result<MappingNodeRoot> {
let mut mapping_node = MappingNode::default();
let mut concatenate_fields = Vec::new();
let mut concatenate_dynamic_fields = Vec::new();
for entry in entries {
if let FieldMappingType::Concatenate(_) = &entry.mapping_type {
concatenate_fields.push(entry);
} else {
field_path.push(&entry.name);
if mapping_node.branches.contains_key(&entry.name) {
bail!("duplicated field definition `{}`", entry.name);
}
let (child_tree, mut dynamic_fields) =
build_mapping_from_field_type(&entry.mapping_type, field_path, schema)?;
field_path.pop();
mapping_node.insert(&entry.name, child_tree);
concatenate_dynamic_fields.append(&mut dynamic_fields);
}
}
for concatenate_field_entry in concatenate_fields {
let FieldMappingType::Concatenate(options) = &concatenate_field_entry.mapping_type else {
// we only pushed Concatenate fields in `concatenate_fields`
unreachable!();
};
let name = &concatenate_field_entry.name;
if mapping_node.branches.contains_key(name) {
bail!("duplicated field definition `{}`", name);
}
let text_options: JsonObjectOptions = options.clone().into();View on GitHub (pinned to a39730c5cd)
Solutions
- Remove or rename the duplicate field definition in the index config mapping.
- If merging configs programmatically, deduplicate entries by name before building the tree.
- Search the YAML/JSON mapping for repeated keys (some editors hide duplicate keys).
Example fix
// before
mapping:
message:
type: text
message:
type: json
// after
mapping:
message:
type: text Defensive patterns
Strategy: validation
Validate before calling
fn check_duplicate_fields(mapping: &serde_yaml::Mapping) -> Result<(), String> {
let mut seen = std::collections::HashSet::new();
for (k, _) in mapping {
if !seen.insert(k.clone()) {
return Err(format!("duplicated field definition `{k:?}`"));
}
}
Ok(())
} Try / catch
match result {
Err(e) if e.to_string().contains("duplicated field definition") => {
// surface the offending config path to the user
}
Err(e) => return Err(e),
Ok(v) => v,
} Prevention
- Deduplicate entries when merging mapping configs.
- Use an editor/linter that highlights duplicate YAML keys.
- Review include/merge logic for double-added field blocks.
When it happens
Trigger: Calling build_mapping_tree (index config load / DocMapping validation) with a mapping containing two fields of the same name in the same object, e.g. `message` declared twice, including duplicates arising from nested objects each contributing a child of the same name.
Common situations: Merged index configs where two include files define the same field; YAML anchors or generated mappings appending a field twice; a copy-pasted field block left in place during edits.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- field name is empty
- field name `{}` must not start with a dot `.`
- field name `{}` is too long. field names must not be longer
- field name `{}` is invalid. field names must start with an u
- field name `{}` contains illegal characters. field names mus
AI-assisted analysis of quickwit-oss/quickwit@a39730c5cd (2026-09-08).
Data as JSON: /api/errors/0150e6ebfc84d6a8.
Report an issue: GitHub.