windmill-labs/windmill · error

You must at least choose schema to fetch table from

Error message

You must at least choose schema to fetch table from

What it means

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.

Source

Thrown at backend/windmill-trigger-postgres/src/handler.rs:992

pub async fn create_template_script(
    authed: ApiAuthed,
    Extension(user_db): Extension<UserDB>,
    Extension(db): Extension<DB>,
    Path(w_id): Path<String>,
    Json(template_script): Json<TemplateScript>,
) -> Result<String> {
    let TemplateScript { postgres_resource_path, relations, language } = template_script;

    check_scopes(&authed, || {
        format!("postgres_triggers:write:{}", postgres_resource_path)
    })?;

    let relations = match relations {
        Some(r) => r,
        None => {
            return Err(
                anyhow::anyhow!("You must at least choose schema to fetch table from").into(),
            )
        }
    };

    let pg_connection: Client = get_default_pg_connection(
        authed.clone(),
        Some(user_db.clone()),
        &db,
        &postgres_resource_path,
        &w_id,
    )
    .await
    .map_err(to_anyhow)?;

    let mut schema_or_fully_qualified_name = Vec::with_capacity(relations.len());
    let mut columns_list = Vec::with_capacity(relations.len());

    for relation in relations {

View on GitHub (pinned to e474e8803c)

Solutions

  1. Include relations in the request body with at least the schema (and table) selected
  2. In the UI, pick a schema and table before submitting the template creation form
  3. Update the API client to the current payload schema if it predates the relations field
  4. Send an explicit non-null relations value — null and omitted are both rejected

Example fix

// before
POST .../script_templates/postgres  body: {"path": "my_script"}
// after
POST .../script_templates/postgres  body: {"path": "my_script", "relations": {"schema": "public", "table": "users"}}
Defensive patterns

Strategy: validation

Validate before calling

// before calling the template endpoint, require relations
function validateTemplatePayload(p) {
  if (!p || !p.relations || p.relations.schema == null) {
    throw new Error('You must at least choose schema to fetch table from');
  }
  return p;
}

Try / catch

try {
  await api.createTemplateScript({ path, relations });
} catch (e) {
  if (String(e).includes('choose schema to fetch table from')) {
    // prompt user to pick schema/table in the wizard, then retry
  } else throw e;
}

Prevention

When it happens

Trigger: Calling the create-template-script endpoint without passing relations in the payload — relations deserializes to None.

Common situations: 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.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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