{"record":{"id":"3eb11e4466892a13","repo":"quickwit-oss/quickwit","slug":"failed-to-compile-vrl-script-formatter","errorCode":null,"errorMessage":"failed to compile VRL script:\n {formatter}","messagePattern":"failed to compile VRL script:\n (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"quickwit/quickwit-config/src/source_config/mod.rs","lineNumber":691,"sourceCode":"        use anyhow::Context;\n        let timezone = vrl::compiler::TimeZone::parse(&self.timezone).with_context(|| {\n            format!(\n                \"failed to parse timezone: `{}`. timezone must be a valid name \\\n            in the TZ database: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones\",\n                self.timezone,\n            )\n        })?;\n        // Append \"\\n.\" to the script to return the entire document and not only the modified\n        // fields.\n        let vrl_script = self.vrl_script.clone() + \"\\n.\";\n        let functions = vrl::stdlib::all();\n\n        let compilation_res = match vrl::compiler::compile(&vrl_script, &functions) {\n            Ok(compilation_res) => compilation_res,\n            Err(diagnostics) => {\n                let mut formatter = vrl::diagnostic::Formatter::new(&vrl_script, diagnostics);\n                formatter.enable_colors(!quickwit_common::no_color());\n                anyhow::bail!(\"failed to compile VRL script:\\n {formatter}\")\n            }\n        };\n\n        let vrl::compiler::CompilationResult {\n            program, warnings, ..\n        } = compilation_res;\n\n        if !warnings.is_empty() {\n            let mut formatter = vrl::diagnostic::Formatter::new(&vrl_script, warnings);\n            formatter.enable_colors(!quickwit_common::no_color());\n            tracing::warn!(\"VRL program compiled with some warnings: {formatter}\");\n        }\n        Ok((program, timezone))\n    }\n\n    #[cfg(any(test, feature = \"testsuite\"))]\n    pub fn for_test(vrl_script: &str) -> Self {\n        Self {","sourceCodeStart":673,"sourceCodeEnd":709,"githubUrl":"https://github.com/quickwit-oss/quickwit/blob/a39730c5cdcd1a4fe798403737ae293999ea21f8/quickwit/quickwit-config/src/source_config/mod.rs#L673-L709","documentation":"When building a source config with a VRL transform, Quickwit compiles the VRL program with `vrl::compiler::compile`. If compilation produces diagnostics (syntax errors, unknown functions, type errors), the diagnostics are formatted and the config build fails with this message containing the formatted VRL error output. This is a user-script validation failure, not an internal bug.","triggerScenarios":"Defining a `source_config` with a VRL transform whose program fails `vrl::compiler::compile` — syntax error, call to a nonexistent VRL function, or type misuse in the transform script.","commonSituations":"Copy-pasted VRL snippets referencing functions not registered in Quickwit's VRL function list; unbalanced braces/quotes; using `.field` on a non-object; wrong argument types to functions like `parse_timestamp`.","solutions":["Read the formatted diagnostics printed after the message header — they point at the exact line/column and reason in the VRL script.","Fix the VRL syntax/type error (correct function name, cast values, balance quotes/braces).","Verify the function exists in the VRL version bundled with your Quickwit; some functions may be unavailable or renamed."],"exampleFix":"# before (unbalanced paren, missing error handling)\nvrl_transform: |\n  .timestamp = parse_timestamp(.ts, \"%+\n\n# after\nvrl_transform: |\n  .timestamp = parse_timestamp!(.ts, \"%+\")","handlingStrategy":"validation","validationCode":"// validate VRL before embedding it in a source config\nlet script = VrlScript::parse(&vrl_source)?;\nlet functions = quickwit_vrl_functions();\nif let Err(diagnostics) = vrl::compiler::compile(&script, &functions) {\n    let mut f = vrl::diagnostic::Formatter::new(&script, diagnostics);\n    f.enable_colors(false);\n    anyhow::bail!(\"invalid VRL transform:\\n{f}\");\n}","typeGuard":null,"tryCatchPattern":"match load_source_config(&cfg) {\n    Ok(sc) => register(sc),\n    Err(e) if e.to_string().contains(\"failed to compile VRL script\") => {\n        eprintln!(\"VRL error — fix the transform script:\\n{}\", e);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Test VRL transforms with the `vrl` CLI or unit tests before adding them to source configs.","Only use functions available in Quickwit's registered VRL function list for your version.","Use fallible variants (`parse_json!`) and handle errors explicitly in-script."],"tags":["rust","config","vrl"],"backgroundTag":"invalid-regex-pattern","analyzedSha":"a39730c5cdcd1a4fe798403737ae293999ea21f8","analyzedAt":"2026-09-08T13:19:37.784Z","contentChangedAt":"2026-09-08T13:19:37.784Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}