iflytek/astron-agent · error · ValueError

When mode= , tableName is required.

Error message

When mode={mode}, tableName is required.

What it means

Pydantic field validator on the PGSQL node's `tableName` field. Modes 1-4 (INSERT/UPDATE/SELECT/DELETE) operate on a table, so `tableName` must be a non-empty string; otherwise model construction raises ValueError (pydantic ValidationError).

Solutions

  1. Set a valid `tableName` in the node config when using any non-CUSTOM mode.
  2. If no table applies, use mode=0 (CUSTOM) with explicit SQL instead.
  3. Enforce table selection in the workflow editor UI before saving the node.
  4. Surface the pydantic ValidationError per-field at import/debug time so the author immediately sees tableName is missing.

Example fix

// before
PgsqlNodeData(mode=2, tableName="", cases=[...])
// after
PgsqlNodeData(mode=2, tableName="users", cases=[...])
Defensive patterns

Strategy: validation

Validate before calling

def validate_table_name(node_cfg: dict):
    if node_cfg.get("mode") in (1, 2, 3, 4) and not (node_cfg.get("tableName") or "").strip():
        raise ValueError(f"mode={node_cfg['mode']} requires tableName")

Type guard

def has_table_name(cfg) -> bool:
    return cfg.mode == 0 or bool(cfg.tableName and cfg.tableName.strip())

Try / catch

try:
    node_data = PgsqlNodeData(**cfg)
except ValidationError as e:
    if any("tableName is required" in err["msg"] for err in e.errors()):
        show_field_error("tableName", "Select a target table")
    raise

Prevention

When it happens

Trigger: Constructing PgsqlNodeData with mode in (1,2,3,4) and `tableName` set to None, empty, or whitespace-only.

Common situations: Workflow author picks a DML mode but forgets to select the target table; frontend sends a stale node config after table selection was cleared; template import missing tableName.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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

Appendix: source

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

        if info.data.get("mode") == 0 and (v is None or v.strip() == ""):
            raise ValueError(
                "When mode=0 (CUSTOM), sql is required and must not be empty."
            )
        return v

    @field_validator("tableName", mode="after")
    def _check_table_name(cls, v: str | None, info: ValidationInfo) -> str | None:
        """
        Check if the table name is valid for the given mode.

        :param v: Table name string
        :param info: ValidationInfo
        :return: Table name string
        :raises ValueError: If the table name is invalid
        """
        mode = info.data.get("mode")
        if mode in (1, 2, 3, 4) and (v is None or v.strip() == ""):
            raise ValueError(f"When mode={mode}, tableName is required.")
        return v

    @field_validator("cases", mode="after")
    def _check_cases_for_update_delete(
        cls, v: List[Case], info: ValidationInfo
    ) -> List[Case]:
        """
        Check if the cases are valid for the given mode.

        :param v: Cases list
        :param info: ValidationInfo
        :return: Cases list
        :raises ValueError: If the cases are invalid
        """
        mode = info.data.get("mode")
        if mode in (2, 4) and not v:
            raise ValueError(
                "When mode=2 (UPDATE) or mode=4 (DELETE), cases cannot be empty."

View on GitHub (pinned to 5e758547a8)