{"record":{"id":"5ca026e2ab8bfd71","repo":"windmill-labs/windmill","slug":"you-must-at-least-choose-schema-to-fetch-table-fro","errorCode":null,"errorMessage":"You must at least choose schema to fetch table from","messagePattern":"You must at least choose schema to fetch table from","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/windmill-trigger-postgres/src/handler.rs","lineNumber":992,"sourceCode":"\npub async fn create_template_script(\n    authed: ApiAuthed,\n    Extension(user_db): Extension<UserDB>,\n    Extension(db): Extension<DB>,\n    Path(w_id): Path<String>,\n    Json(template_script): Json<TemplateScript>,\n) -> Result<String> {\n    let TemplateScript { postgres_resource_path, relations, language } = template_script;\n\n    check_scopes(&authed, || {\n        format!(\"postgres_triggers:write:{}\", postgres_resource_path)\n    })?;\n\n    let relations = match relations {\n        Some(r) => r,\n        None => {\n            return Err(\n                anyhow::anyhow!(\"You must at least choose schema to fetch table from\").into(),\n            )\n        }\n    };\n\n    let pg_connection: Client = get_default_pg_connection(\n        authed.clone(),\n        Some(user_db.clone()),\n        &db,\n        &postgres_resource_path,\n        &w_id,\n    )\n    .await\n    .map_err(to_anyhow)?;\n\n    let mut schema_or_fully_qualified_name = Vec::with_capacity(relations.len());\n    let mut columns_list = Vec::with_capacity(relations.len());\n\n    for relation in relations {","sourceCodeStart":974,"sourceCodeEnd":1010,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/windmill-trigger-postgres/src/handler.rs#L974-L1010","documentation":"create_template_script builds a starter script from a PostgreSQL table. The relations parameter (which schema/table to base the template on) is optional; if absent, the handler rejects the request with this message because it cannot fetch a table without at least a schema.","triggerScenarios":"Calling the create-template-script endpoint without passing relations in the payload — relations deserializes to None.","commonSituations":"Omitting the relations field in the request body; frontend/API client sending an older payload shape; selecting a connection but forgetting to pick schema/table in the template wizard; null vs missing field confusion in typed clients.","solutions":["Include relations in the request body with at least the schema (and table) selected","In the UI, pick a schema and table before submitting the template creation form","Update the API client to the current payload schema if it predates the relations field","Send an explicit non-null relations value — null and omitted are both rejected"],"exampleFix":"// before\nPOST .../script_templates/postgres  body: {\"path\": \"my_script\"}\n// after\nPOST .../script_templates/postgres  body: {\"path\": \"my_script\", \"relations\": {\"schema\": \"public\", \"table\": \"users\"}}","handlingStrategy":"validation","validationCode":"// before calling the template endpoint, require relations\nfunction validateTemplatePayload(p) {\n  if (!p || !p.relations || p.relations.schema == null) {\n    throw new Error('You must at least choose schema to fetch table from');\n  }\n  return p;\n}","typeGuard":null,"tryCatchPattern":"try {\n  await api.createTemplateScript({ path, relations });\n} catch (e) {\n  if (String(e).includes('choose schema to fetch table from')) {\n    // prompt user to pick schema/table in the wizard, then retry\n  } else throw e;\n}","preventionTips":["Validate the request body client-side before submission (relations.schema required)","Keep the template wizard's submit button disabled until a schema/table is selected","Update generated API clients when the payload schema gains required fields","Distinguish 'missing field' from 'explicit null' — both are rejected here"],"tags":["postgres","validation","missing-parameter","templates"],"backgroundTag":"missing-required-argument","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"}