quickwit-oss/quickwit · error

err_msg

Error message

err_msg

What it means

This error originates from converting the f64 boost value in a user query AST into a NotNaNf32. If the boost value is NaN (or otherwise fails NotNaNf32 validation), the conversion returns a string error which is wrapped into an anyhow error. It means the user's query contained a boost clause with a value that cannot be represented as a valid non-NaN f32.

Source

Thrown at quickwit/quickwit-query/src/query_ast/user_input_query.rs:202

                    bail!("regex query with multiple fields is not supported");
                };
                let regex_query = query_ast::RegexQuery {
                    field,
                    regex: pattern,
                };
                Ok(regex_query.into())
            }
        },
        UserInputAst::Boost(underlying, boost) => {
            let query_ast = convert_user_input_ast_to_query_ast(
                *underlying,
                default_occur,
                default_search_fields,
                lenient,
            )?;
            let boost: NotNaNf32 = (boost.into_inner() as f32)
                .try_into()
                .map_err(|err_msg: &str| anyhow::anyhow!(err_msg))?;
            Ok(QueryAst::Boost {
                underlying: Box::new(query_ast),
                boost,
            })
        }
    }
}

fn is_wildcard(phrase: &str) -> bool {
    use std::ops::ControlFlow;
    enum State {
        Normal,
        Escaped,
    }

    phrase
        .chars()
        .try_fold(State::Normal, |state, c| match state {

View on GitHub (pinned to a39730c5cd)

Solutions

  1. Inspect the query string/payload and remove or fix the BOOST clause value that is NaN.
  2. Validate boost numbers before embedding them in the query: reject anything where value != value (NaN) or is not finite.
  3. Use a sane default boost (e.g. 1.0) when a computed boost is invalid instead of passing it through.

Example fix

// before
let boost_val = score / weight; // may be NaN when weight == 0.0
let q = format!("BOOST:{}({})", boost_val, field);
// after
let boost_val = if weight == 0.0 { 1.0 } else { score / weight };
let boost_val = if boost_val.is_finite() { boost_val } else { 1.0 };
let q = format!("BOOST:{}({})", boost_val, field);
Defensive patterns

Strategy: validation

Validate before calling

fn validate_boost(v: f64) -> Result<f64, String> {
    if !v.is_finite() { Err(format!("boost must be finite, got {v}")) } else { Ok(v) }
}

Type guard

fn is_valid_boost(v: &serde_json::Value) -> bool {
    v.as_f64().map(|f| f.is_finite()).unwrap_or(false)
}

Try / catch

match parse_user_query(&query, ...) {
    Ok(ast) => ast,
    Err(e) if e.to_string().contains("boost") => {
        eprintln!("invalid boost in query: {e}");
        default_query
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling parse_user_query on a query string whose BOOST(...) clause carries a boost value that is NaN (e.g. computed or serialized as NaN) so that `boost.into_inner() as f32` fails `try_into::<NotNaNf32>()`.

Common situations: Programmatic query construction that injects computed boost values; JSON query payloads where a null/NaN became NaN; serialization round-trips that corrupt the boost number.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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