quickwit-oss/quickwit · error · anyhow::Error

failed to compile VRL script: {formatter}

Error message

failed to compile VRL script:
 {formatter}

What it means

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.

Source

Thrown at quickwit/quickwit-config/src/source_config/mod.rs:691

        use anyhow::Context;
        let timezone = vrl::compiler::TimeZone::parse(&self.timezone).with_context(|| {
            format!(
                "failed to parse timezone: `{}`. timezone must be a valid name \
            in the TZ database: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones",
                self.timezone,
            )
        })?;
        // Append "\n." to the script to return the entire document and not only the modified
        // fields.
        let vrl_script = self.vrl_script.clone() + "\n.";
        let functions = vrl::stdlib::all();

        let compilation_res = match vrl::compiler::compile(&vrl_script, &functions) {
            Ok(compilation_res) => compilation_res,
            Err(diagnostics) => {
                let mut formatter = vrl::diagnostic::Formatter::new(&vrl_script, diagnostics);
                formatter.enable_colors(!quickwit_common::no_color());
                anyhow::bail!("failed to compile VRL script:\n {formatter}")
            }
        };

        let vrl::compiler::CompilationResult {
            program, warnings, ..
        } = compilation_res;

        if !warnings.is_empty() {
            let mut formatter = vrl::diagnostic::Formatter::new(&vrl_script, warnings);
            formatter.enable_colors(!quickwit_common::no_color());
            tracing::warn!("VRL program compiled with some warnings: {formatter}");
        }
        Ok((program, timezone))
    }

    #[cfg(any(test, feature = "testsuite"))]
    pub fn for_test(vrl_script: &str) -> Self {
        Self {

View on GitHub (pinned to a39730c5cd)

Solutions

  1. Read the formatted diagnostics printed after the message header — they point at the exact line/column and reason in the VRL script.
  2. Fix the VRL syntax/type error (correct function name, cast values, balance quotes/braces).
  3. Verify the function exists in the VRL version bundled with your Quickwit; some functions may be unavailable or renamed.

Example fix

# before (unbalanced paren, missing error handling)
vrl_transform: |
  .timestamp = parse_timestamp(.ts, "%+

# after
vrl_transform: |
  .timestamp = parse_timestamp!(.ts, "%+")
Defensive patterns

Strategy: validation

Validate before calling

// validate VRL before embedding it in a source config
let script = VrlScript::parse(&vrl_source)?;
let functions = quickwit_vrl_functions();
if let Err(diagnostics) = vrl::compiler::compile(&script, &functions) {
    let mut f = vrl::diagnostic::Formatter::new(&script, diagnostics);
    f.enable_colors(false);
    anyhow::bail!("invalid VRL transform:\n{f}");
}

Try / catch

match load_source_config(&cfg) {
    Ok(sc) => register(sc),
    Err(e) if e.to_string().contains("failed to compile VRL script") => {
        eprintln!("VRL error — fix the transform script:\n{}", e);
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: 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.

Common situations: 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`.

Related errors


AI-assisted analysis of quickwit-oss/quickwit@a39730c5cd (2026-09-08). Data as JSON: /api/errors/3eb11e4466892a13. Report an issue: GitHub.