iflytek/astron-agent · error · CustomException

PG_SQL_PARAM_ERROR

PG_SQL_PARAM_ERROR

Error message

Database DML statement generation failed: WHERE condition is empty

What it means

`generate_update_statement` builds the WHERE clause for an UPDATE from the configured cases. If joining the case parts yields an empty WHERE clause (e.g. all cases rendered empty), it refuses to emit an UPDATE without a WHERE and raises PG_SQL_PARAM_ERROR, preventing a full-table update.

Solutions

  1. Inspect the node's cases and ensure each has a non-empty column, operator, and a resolvable value.
  2. Check upstream variable references in case values — unresolved variables may render as empty strings and drop the condition.
  3. Add a pre-check in generate_update_statement that filters out blank parts and errors earlier with a per-case message.
  4. Re-save the node in the editor so validators re-run and surface the incomplete condition to the author.

Example fix

// before
cases=[Case(column="", operator="=", value="{{var}}")]  # renders empty WHERE
// after
cases=[Case(column="id", operator="=", value="42")]
Defensive patterns

Strategy: validation

Validate before calling

def cases_render_nonempty(cases):
    return all(c.column and c.column.strip() and c.value not in (None, "") for c in cases)

Type guard

def update_has_where(cfg) -> bool:
    return cfg.mode != 2 or cases_render_nonempty(cfg.cases)

Try / catch

try:
    sql = await node.generate_dml(span)
except CustomException as e:
    if "WHERE condition is empty" in str(e):
        log.error("UPDATE would run without WHERE; check case values/variables")
    raise

Prevention

When it happens

Trigger: Calling `generate_dml` for an UPDATE node where every Case in `cases` produces an empty SQL fragment (empty column/value templates, all-None evaluated parts) so `where_clause` is falsy despite passing model validation.

Common situations: Case fields reference workflow variables that resolved to empty strings; template placeholders left unfilled; cases populated with blank rows via API that bypassed UI validation.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12). Data as JSON: /api/errors/950f8a0b381021f6. Report an issue: GitHub.

Appendix: source

Thrown at core/workflow/engine/nodes/pgsql/pgsql_node.py:269

            else:
                if op in ("LIKE", "NOT LIKE"):
                    val = f"%{val}%"
                placeholder = f":w_val_{w_idx}"
                part = f"{fld} {op} {placeholder}"
                params[f"w_val_{w_idx}"] = val
                w_idx += 1

            parts.append(part)

        # Combine conditions with logical operator
        where_clause = f" {case.logicalOperator.upper()} ".join(parts)
        if where_clause:
            sql = f"UPDATE {self.tableName} SET {set_clause} WHERE {where_clause};"
            stmt = text(sql).bindparams(**params)
            return str(stmt.compile(compile_kwargs={"literal_binds": True}))
        else:
            raise CustomException(
                err_code=CodeEnum.PG_SQL_PARAM_ERROR,
                err_msg="Database DML statement generation failed: WHERE condition is empty",
                cause_error="Database DML statement generation failed: WHERE condition is empty",
            )

    def generate_delete_statement(self, case: Case) -> str:
        """Generate DELETE SQL statement with WHERE conditions.

        :param condition: Dictionary containing WHERE clause conditions
        :return: Formatted DELETE SQL statement
        :raises CustomException: If WHERE conditions are empty or invalid
        """
        # Build WHERE clause conditions for DELETE statement
        parts = []
        params = {}
        idx = 0

        for condition in case.conditions:

View on GitHub (pinned to 5e758547a8)