windmill-labs/windmill · error

Unsupported JSON array type

Error message

Unsupported JSON array type

What it means

The PostgreSQL step's array converter (convert_vec_val) maps a JSON array argument to a Postgres array type based on the declared arg type string. When the arg_t is not one of the supported element types (e.g. text, int, bigint, numeric, bool, etc.), the match falls through to the catch-all arm and raises 'Unsupported JSON array type'. It exists because the executor cannot safely serialize the array elements to a tokio-postgres Type without a recognized mapping.

Source

Thrown at backend/windmill-worker/src/pg_executor.rs:1411

                        .decode(x)
                        .unwrap_or(vec![])
                })
            })?),
            Type::BYTEA_ARRAY,
        )),
        "varchar" | "character varying" => Ok((
            Box::new(map_as_single_type(vec, |v| {
                v.as_str().map(|x| x.to_string())
            })?),
            Type::VARCHAR_ARRAY,
        )),
        "text" => Ok((
            Box::new(map_as_single_type(vec, |v| {
                v.as_str().map(|x| x.to_string())
            })?),
            Type::TEXT_ARRAY,
        )),
        _ => Err(anyhow::anyhow!("Unsupported JSON array type"))?,
    }
}

fn convert_val(
    value: &Value,
    arg_t: &String,
    typ: &Typ,
    otyp_inferred: bool,
) -> windmill_common::error::Result<ConvertedParam> {
    // Helper: was the user's intent explicitly "text" / "varchar" / "char"?
    // True when the parser saw an inline `$N::text` cast or a `-- $N (text)`
    // declaration. False when the parser fell back to "text" because nothing
    // else was found (in which case the caller has no real target type
    // committed and we should bind the value's natural type).
    let explicit_text_target = !otyp_inferred
        && (matches!(typ, Typ::Str(_))
            && (arg_t == "text"
                || arg_t == "varchar"

View on GitHub (pinned to e474e8803c)

Solutions

  1. Check the arg_t string in the step's args for typos and use one of the supported array element types (text, int/integer/int4, bigint/int8, numeric, bool, etc.)
  2. Cast to a supported type in SQL: pass the array as text[] and use `SELECT unnest($1::text[])::uuid` inside the query
  3. Serialize the array to a JSON string and parse inside SQL with `jsonb_array_elements_text($1::jsonb)`
  4. If the array element type is widely needed, add a match arm in convert_vec_val mapping it to the corresponding tokio_postgres Type

Example fix

// before (step arg schema)
{ "name": "ids", "type": "uuid[]", "value": ["a", "b"] }
// after
{ "name": "ids", "type": "object", "value": ["a", "b"] }
-- query: SELECT * FROM t WHERE id = ANY(ARRAY(SELECT unnest($1::jsonb)::text)::uuid[])
Defensive patterns

Strategy: validation

Validate before calling

const SUPPORTED_ARRAY_ELEMENT_TYPES = new Set(["text","varchar","int","integer","int4","bigint","int8","numeric","decimal","bool","boolean","real","float4","double","float8"]);
function assertSupportedArrayArg(value, argT) {
  const base = argT.replace(/\[\]$/, "");
  if (Array.isArray(value) && !SUPPORTED_ARRAY_ELEMENT_TYPES.has(base)) {
    throw new Error(`Unsupported JSON array arg type: ${argT}; use a supported element type or cast in SQL`);
  }
}

Type guard

function isSupportedPgArrayArg(v, argT) {
  return !Array.isArray(v) || SUPPORTED_ARRAY_ELEMENT_TYPES.has(argT.replace(/\[\]$/, ""));
}

Prevention

When it happens

Trigger: Passing a JSON array value to a pg query step whose declared argument type is an array type the converter does not recognize (e.g. a custom enum array, uuid[], json[], or a typo like 'textt[]'), so the match arm in convert_vec_val hits the `_ =>` branch.

Common situations: Typo in the arg type in the step's arg schema; using a less-common Postgres array element type (uuid[], jsonb[], inet[], timestamptz[]) that the converter lacks a mapping for; copying a type name from PG docs that the step UI doesn't accept.

Related errors


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