{"record":{"id":"33b05f7c1d3346c7","repo":"quickwit-oss/quickwit","slug":"the-list-of-index-id-patterns-may-not-be-empty","errorCode":null,"errorMessage":"The list of index id patterns may not be empty.","messagePattern":"The list of index id patterns may not be empty\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"quickwit/quickwit-metastore/src/metastore/postgres/metastore.rs","lineNumber":3135,"sourceCode":"\n/// Builds the SQL query that returns indexes matching at least one pattern in\n/// `index_id_patterns`, and none of the patterns starting with '-'\n///\n/// For each pattern, we check whether the pattern is valid and replace `*` by `%`\n/// to build a SQL `LIKE` query.\nfn build_index_id_patterns_sql_query(index_id_patterns: &[String]) -> anyhow::Result<String> {\n    let mut positive_patterns = Vec::new();\n    let mut negative_patterns = Vec::new();\n    for pattern in index_id_patterns {\n        if let Some(negative_pattern) = pattern.strip_prefix('-') {\n            negative_patterns.push(negative_pattern.to_string());\n        } else {\n            positive_patterns.push(pattern);\n        }\n    }\n\n    if positive_patterns.is_empty() {\n        anyhow::bail!(\"The list of index id patterns may not be empty.\");\n    }\n\n    if index_id_patterns.iter().any(|pattern| pattern == \"*\") && negative_patterns.is_empty() {\n        return Ok(\"SELECT * FROM indexes\".to_string());\n    }\n\n    let mut where_like_query = String::new();\n    for (index_id_pattern_idx, index_id_pattern) in positive_patterns.iter().enumerate() {\n        validate_index_id_pattern(index_id_pattern, false).map_err(|error| {\n            MetastoreError::Internal {\n                message: \"failed to build list indexes query\".to_string(),\n                cause: error.to_string(),\n            }\n        })?;\n        if index_id_pattern_idx != 0 {\n            where_like_query.push_str(\" OR \");\n        }\n        if index_id_pattern.contains('*') {","sourceCodeStart":3117,"sourceCodeEnd":3153,"githubUrl":"https://github.com/quickwit-oss/quickwit/blob/a39730c5cdcd1a4fe798403737ae293999ea21f8/quickwit/quickwit-metastore/src/metastore/postgres/metastore.rs#L3117-L3153","documentation":"Thrown while building a SQL WHERE clause from index id patterns for the PostgreSQL metastore when the resulting positive (non-excluded) pattern list is empty — i.e. every pattern was a negation (leading '-') or empty, so no rows could match.","triggerScenarios":"Calling a metastore list/query operation with index_id_patterns consisting only of negative patterns like [\"-foo\", \"-bar\"], or all patterns being empty strings.","commonSituations":"Passing a CLI flag like --index-id-pattern '-myindex*' with no positive pattern; constructing query filters programmatically from empty user input.","solutions":["Include at least one positive pattern, e.g. combine \"*\" with negations: [\"*\", \"-myindex*\"]","If excluding only, list the indexes to include explicitly instead","Validate the pattern list in the caller before invoking the metastore query"],"exampleFix":"// before\nlet patterns = vec![\"-stale-*\".to_string()];\n// after\nlet patterns = vec![\"*\".to_string(), \"-stale-*\".to_string()];","handlingStrategy":"validation","validationCode":"fn has_positive_pattern(pats: &[String]) -> bool {\n    pats.iter().any(|p| !p.is_empty() && !p.starts_with('-'))\n}\nassert!(has_positive_pattern(&patterns), \"need at least one positive pattern\");","typeGuard":null,"tryCatchPattern":"if patterns.iter().all(|p| p.starts_with('-') || p.is_empty()) {\n    patterns.insert(0, \"*\".to_string());\n}\nlist_indexes(&patterns).await?;","preventionTips":["Combine negation patterns with \"*\" when you only want exclusions","Validate pattern lists in the CLI layer before hitting the metastore","Document that all-negative pattern lists are unsupported"],"tags":["metastore","postgres","query","patterns"],"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"}