windmill-labs/windmill · error

Sanitized enum `{}` needs to receive a string

Error message

Sanitized enum `{}` needs to receive a string

What it means

Validation guard inside sanitize_and_interpolate_unsafe_sql_args: an argument whose declared otyp is a sanitized enum must be bound to a string value in the script's args. The error fires when args_map holds a non-string (e.g. a number, object or null) for that enum-typed parameter, so the SQL template cannot safely substitute it.

Source

Thrown at backend/windmill-worker/src/sanitized_sql_params.rs:78

    args: &Vec<Arg>,
    args_map: &HashMap<String, Value>,
    contextual_variables: &HashMap<String, String>,
) -> Result<(String, Vec<String>), error::Error> {
    let mut ret = code.to_string();
    let mut args_to_skip = vec![];

    replace_contextual_variables(&mut ret, contextual_variables);

    for arg in args {
        if let Some(typ) = &arg.otyp {
            let pattern = format!("%%{}%%", arg.name);
            match typ.as_str() {
                SANITIZED_ENUM_STR => {
                    let replace =
                        args_map
                            .get(&arg.name)
                            .and_then(|rv| rv.as_str())
                            .ok_or(anyhow!(
                                "Sanitized enum `{}` needs to receive a string",
                                arg.name
                            ))?;
                    let windmill_parser::Typ::Str(Some(variants)) = &arg.typ else {
                        return Err(error::Error::ArgumentErr(format!(
                            "Wrong type of argument for sanitized enum `{}`",
                            arg.name
                        )));
                    };
                    if variants.iter().all(|v| v != replace) {
                        return Err(error::Error::ArgumentErr(format!(
                            "Sanitized enum argument `{}` expected one of `[{}]` but received `{}`",
                            arg.name,
                            variants
                                .iter()
                                .map(|s| format!("{s}"))
                                .collect::<Vec<String>>()
                                .join(","),

View on GitHub (pinned to e474e8803c)

Solutions

  1. Pass the enum parameter as a plain string matching one of the enum's allowed values
  2. Fix the script schema/parameter declaration so the otyp matches the value actually supplied
  3. Check the flow/app input feeding this script step for a coerced or missing enum value
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at backend/windmill-worker/src/sanitized_sql_params.rs:78 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03). Data as JSON: /api/errors/1010a6ed51f4f6e2. Report an issue: GitHub.