{"record":{"id":"5f2454f4213a8110","repo":"windmill-labs/windmill","slug":"unsupported-json-array-type","errorCode":null,"errorMessage":"Unsupported JSON array type","messagePattern":"Unsupported JSON array type","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/windmill-worker/src/pg_executor.rs","lineNumber":1411,"sourceCode":"                        .decode(x)\n                        .unwrap_or(vec![])\n                })\n            })?),\n            Type::BYTEA_ARRAY,\n        )),\n        \"varchar\" | \"character varying\" => Ok((\n            Box::new(map_as_single_type(vec, |v| {\n                v.as_str().map(|x| x.to_string())\n            })?),\n            Type::VARCHAR_ARRAY,\n        )),\n        \"text\" => Ok((\n            Box::new(map_as_single_type(vec, |v| {\n                v.as_str().map(|x| x.to_string())\n            })?),\n            Type::TEXT_ARRAY,\n        )),\n        _ => Err(anyhow::anyhow!(\"Unsupported JSON array type\"))?,\n    }\n}\n\nfn convert_val(\n    value: &Value,\n    arg_t: &String,\n    typ: &Typ,\n    otyp_inferred: bool,\n) -> windmill_common::error::Result<ConvertedParam> {\n    // Helper: was the user's intent explicitly \"text\" / \"varchar\" / \"char\"?\n    // True when the parser saw an inline `$N::text` cast or a `-- $N (text)`\n    // declaration. False when the parser fell back to \"text\" because nothing\n    // else was found (in which case the caller has no real target type\n    // committed and we should bind the value's natural type).\n    let explicit_text_target = !otyp_inferred\n        && (matches!(typ, Typ::Str(_))\n            && (arg_t == \"text\"\n                || arg_t == \"varchar\"","sourceCodeStart":1393,"sourceCodeEnd":1429,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/windmill-worker/src/pg_executor.rs#L1393-L1429","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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.)","Cast to a supported type in SQL: pass the array as text[] and use `SELECT unnest($1::text[])::uuid` inside the query","Serialize the array to a JSON string and parse inside SQL with `jsonb_array_elements_text($1::jsonb)`","If the array element type is widely needed, add a match arm in convert_vec_val mapping it to the corresponding tokio_postgres Type"],"exampleFix":"// before (step arg schema)\n{ \"name\": \"ids\", \"type\": \"uuid[]\", \"value\": [\"a\", \"b\"] }\n// after\n{ \"name\": \"ids\", \"type\": \"object\", \"value\": [\"a\", \"b\"] }\n-- query: SELECT * FROM t WHERE id = ANY(ARRAY(SELECT unnest($1::jsonb)::text)::uuid[])","handlingStrategy":"validation","validationCode":"const SUPPORTED_ARRAY_ELEMENT_TYPES = new Set([\"text\",\"varchar\",\"int\",\"integer\",\"int4\",\"bigint\",\"int8\",\"numeric\",\"decimal\",\"bool\",\"boolean\",\"real\",\"float4\",\"double\",\"float8\"]);\nfunction assertSupportedArrayArg(value, argT) {\n  const base = argT.replace(/\\[\\]$/, \"\");\n  if (Array.isArray(value) && !SUPPORTED_ARRAY_ELEMENT_TYPES.has(base)) {\n    throw new Error(`Unsupported JSON array arg type: ${argT}; use a supported element type or cast in SQL`);\n  }\n}","typeGuard":"function isSupportedPgArrayArg(v, argT) {\n  return !Array.isArray(v) || SUPPORTED_ARRAY_ELEMENT_TYPES.has(argT.replace(/\\[\\]$/, \"\"));\n}","tryCatchPattern":null,"preventionTips":["Stick to the documented supported arg types in step schemas","Prefer casting arrays inside the SQL text over declaring exotic array arg types","For unsupported element types, pass a JSON string and use jsonb_array_elements_text"],"tags":["postgresql","type-conversion","array","argument-validation"],"backgroundTag":"unsupported-type-cast","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}