{"record":{"id":"92fa9bc389b56e07","repo":"quickwit-oss/quickwit","slug":"error-parsing-routing-expression-e","errorCode":null,"errorMessage":"error parsing routing expression: {e}","messagePattern":"error parsing routing expression: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"quickwit/quickwit-doc-mapper/src/routing_expression/mod.rs","lineNumber":388,"sourceCode":"    use nom::{AsChar, Finish, IResult, Input, Parser};\n\n    // this is a RoutingSubExpr in our DSL.\n    #[derive(Debug, PartialEq, Eq, Clone)]\n    pub(crate) enum ExpressionAst {\n        Field(String),\n        Function { name: String, args: Vec<Argument> },\n    }\n\n    #[derive(Debug, PartialEq, Eq, Clone)]\n    pub(crate) enum Argument {\n        Expression(Vec<ExpressionAst>),\n        Number(u64),\n    }\n\n    pub(crate) fn parse_expression(expr_dsl_str: &str) -> anyhow::Result<Vec<ExpressionAst>> {\n        let (i, res) = routing_expr(expr_dsl_str)\n            .finish()\n            .map_err(|e| anyhow::anyhow!(\"error parsing routing expression: {e}\"))?;\n        eof::<_, ()>(i)?;\n\n        Ok(res)\n    }\n\n    // tag, but ignore leading and trailing whitespaces\n    pub fn wtag<'a, Error: nom::error::ParseError<&'a str>>(\n        t: &'a str,\n    ) -> impl Parser<&'a str, Output = &'a str, Error = Error> {\n        delimited(multispace0, tag(t), multispace0)\n    }\n\n    // DSL:\n    //\n    // RoutingExpr := RoutingSubExpr [ , RoutingExpr ]\n    // RougingSubExpr := Identifier [ \\( Arguments \\) ]\n    // Identifier := FieldChar [ Identifier ]\n    // FieldChar := { a..z | A..Z | 0..9 | _ | . | \\ | / | @ | $ }","sourceCodeStart":370,"sourceCodeEnd":406,"githubUrl":"https://github.com/quickwit-oss/quickwit/blob/a39730c5cdcd1a4fe798403737ae293999ea21f8/quickwit/quickwit-doc-mapper/src/routing_expression/mod.rs#L370-L406","documentation":"The routing expression (partitioning key expression) DSL string is parsed with a nom parser. If the whole string cannot be parsed as a valid routing expression (bad syntax, unbalanced characters, unknown constructs), the parser error is wrapped with this message. It occurs when index partitioning configuration is being interpreted.","triggerScenarios":"Calling `parse_expression` on a `routing_expression` / partitioning DSL string from the index config that is syntactically invalid, e.g. `hash_mod(field_name`, stray characters, or missing closing parentheses.","commonSituations":"Hand-written `indexing.partitioning` config with typos, generated config where a field name contains characters the DSL treats specially, or copy-paste from docs of a different version with changed syntax.","solutions":["Check the wrapped parser error `{e}` for position/details and correct the DSL string syntax.","Verify parentheses and the `hash_mod(...)` expression shape in `indexing.partitioning`.","Escape special characters in field names per the routing expression DSL rules.","Test the expression against the documented routing expression grammar for your Quickwit version."],"exampleFix":"# before\npartitioning:\n  hash_mod: tenant_id\n# after\npartitioning:\n  hash_mod: tenant_id","handlingStrategy":"try-catch","validationCode":"// Basic syntax sanity check before applying config\nif (!/^hash_mod\\([a-zA-Z0-9_.\\\\]+\\)$/.test(expr) && expr.trim() !== \"\") {\n    throw new Error(\"invalid routing expression syntax\");\n}","typeGuard":null,"tryCatchPattern":"match parse_expression(expr) {\n    Err(e) if e.to_string().starts_with(\"error parsing routing expression\") => {\n        // surface the wrapped nom error position to the user\n    }\n    r => r?,\n}","preventionTips":["Copy routing expressions verbatim from docs and adjust only field names.","Escape special characters in field names in the DSL.","Test partitioning config on a dev index before production."],"tags":["parser","routing","config","dsl"],"backgroundTag":"invalid-argument-format","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"}