{"record":{"id":"b1eabbcf3a3a1656","repo":"quickwit-oss/quickwit","slug":"index-id-patterns-must-not-be-empty","errorCode":null,"errorMessage":"`index_id_patterns` must not be empty","messagePattern":"`index_id_patterns` must not be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"quickwit/quickwit-config/src/index_template/mod.rs","lineNumber":87,"sourceCode":"        let mut doc_mapping = self.doc_mapping.clone();\n        doc_mapping.doc_mapping_uid = DocMappingUid::random();\n\n        let index_config = IndexConfig {\n            index_id,\n            index_uri,\n            doc_mapping,\n            indexing_settings: self.indexing_settings.clone(),\n            ingest_settings: self.ingest_settings.clone(),\n            search_settings: self.search_settings.clone(),\n            retention_policy_opt: self.retention_policy_opt.clone(),\n        };\n        Ok(index_config)\n    }\n\n    pub fn validate(&self) -> anyhow::Result<()> {\n        validate_identifier(\"template\", &self.template_id)?;\n\n        ensure!(\n            !self.index_id_patterns.is_empty(),\n            \"`index_id_patterns` must not be empty\"\n        );\n        for index_id_pattern in &self.index_id_patterns {\n            validate_index_id_pattern(index_id_pattern, true)?;\n        }\n        validate_index_config(\n            &self.doc_mapping,\n            &self.indexing_settings,\n            &self.search_settings,\n            &self.retention_policy_opt,\n        )?;\n        Ok(())\n    }\n\n    #[cfg(any(test, feature = \"testsuite\"))]\n    pub fn for_test(template_id: &str, index_id_patterns: &[&str], priority: usize) -> Self {\n        let index_id_patterns: Vec<IndexIdPattern> = index_id_patterns","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/quickwit-oss/quickwit/blob/a39730c5cdcd1a4fe798403737ae293999ea21f8/quickwit/quickwit-config/src/index_template/mod.rs#L69-L105","documentation":"`IndexTemplate::validate` requires an index template to declare at least one `index_id_pattern`, since a template with no patterns can never match any index id. Before checking each pattern's validity, it ensures the list is not empty and fails fast with this message.","triggerScenarios":"Submitting an index template (via the template API or a template config file) where the `index_id_patterns` array is missing or empty `[]`.","commonSituations":"Creating a template programmatically and forgetting to populate patterns; a config generation bug that emits an empty list; cleaning out patterns before re-adding them and applying the half-finished template.","solutions":["Add at least one index id pattern, e.g. `index_id_patterns: [\"my-index-*\"]`","If the template should not match anything, remove the template instead of emptying its patterns","Validate the generated template JSON/YAML before submission"],"exampleFix":"// before\nindex_id_patterns: []\n// after\nindex_id_patterns:\n  - \"my-index-*\"","handlingStrategy":"validation","validationCode":"function validateTemplate(tpl) {\n  if (!Array.isArray(tpl.index_id_patterns) || tpl.index_id_patterns.length === 0) {\n    throw new Error(\"index_id_patterns must contain at least one pattern\");\n  }\n  return true;\n}","typeGuard":"function hasIndexIdPatterns(tpl) {\n  return Array.isArray(tpl.index_id_patterns) && tpl.index_id_patterns.length > 0;\n}","tryCatchPattern":"try {\n  client.sendIndexTemplateRequest(request).await?;\n} catch (e) {\n  if (e.message.includes(\"`index_id_patterns` must not be empty\")) {\n    console.error(\"Add at least one index_id_pattern to the template.\");\n  } else { throw e; }\n}","preventionTips":["Always declare at least one wildcard pattern (e.g. `logs-*`) when authoring a template","Lint template JSON/YAML for empty arrays before submission","Remove unused templates entirely rather than stripping their patterns"],"tags":["config","validation","index-template"],"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-17T15:17:12.973Z"}