iflytek/astron-agent · error · CustomException

PG_SQL_PARAM_ERROR

PG_SQL_PARAM_ERROR

Error message

Invalid {field_type}: {key} is a reserved keyword in database

What it means

FileConfig.is_valid (key validation helper) raises CustomException PG_SQL_PARAM_ERROR when a field or column key matches an entry in DB_SQL_INVALID_KEY, i.e. a PostgreSQL reserved keyword. Such keys would break or risk injection when used in generated SQL identifiers for knowledge-base fields.

Solutions

  1. Rename the field to a non-reserved identifier, e.g. 'order' -> 'order_name' or 'order_value'
  2. Prefix/suffix reserved keys automatically before persisting (e.g. wrap in quotes or add 'f_' prefix)
  3. Validate user-provided field names against DB_SQL_INVALID_KEY at the API boundary and reject early with a clear message
  4. Consult the PostgreSQL reserved keyword list when designing field names

Example fix

// before
field_key = "order"       # reserved keyword -> PG_SQL_PARAM_ERROR
// after
field_key = "order_value"
Defensive patterns

Strategy: validation

Validate before calling

from workflow.configs.app_config import DB_SQL_INVALID_KEY
if key.lower() in DB_SQL_INVALID_KEY:
    raise FieldNameRejected(f"{key!r} is a reserved SQL keyword")

Try / catch

try:
    file_config.validate_key(key, field_type="field")
except CustomException as e:
    if e.err_code == CodeEnum.PG_SQL_PARAM_ERROR:
        return field_error(suggest=f"{key}_value")
    raise

Prevention

When it happens

Trigger: Creating/updating a dataset or table field named 'order', 'select', 'group', 'user', etc.; importing a schema (CSV headers, JSON keys) whose column name is a SQL reserved word; case-insensitive match caught via key.lower().

Common situations: CSV header 'order' imported as a knowledge base field; user names a metadata field 'desc'; upstream rename introduces a reserved word into the schema sync.

Understand the failure class

Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.

Related errors


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

Appendix: source

Thrown at core/workflow/configs/app_config.py:165

    PostgreSQL configuration model.

    This model represents the PostgreSQL configuration with its keyword list.
    """

    model_config = {"env_prefix": "", "case_sensitive": False}
    keyword_list: List[str] = Field(default=DB_SQL_INVALID_KEY, alias="KEYWORD_LIST")

    def is_valid(self, key: str, field_type: str) -> None:
        """
        Validate if the key is valid.

        :param key: The key to validate
        :param field_type: The type of the field
        :raises CustomException: If the key is not valid
        """
        key_lower = key.lower()
        if key_lower in DB_SQL_INVALID_KEY:
            raise CustomException(
                err_code=CodeEnum.PG_SQL_PARAM_ERROR,
                err_msg=f"Invalid {field_type}: {key} is a reserved keyword in database",
                cause_error=f"Invalid {field_type}: {key} is a reserved keyword in database",
            )


class KafkaConfig(BaseSettings):
    """
    Kafka configuration model.

    This model represents the Kafka configuration with its various settings.
    Attributes:
        kafka_servers: Kafka broker addresses, comma-separated
        kafka_protocol: Security protocol (PLAINTEXT, SASL_PLAINTEXT, SSL, SASL_SSL)
        kafka_mechanism: SASL mechanism (PLAIN, SCRAM-SHA-256, SCRAM-SHA-512)
        kafka_username: SASL username
        kafka_password: SASL password
        kafka_enable: Whether Kafka is enabled (0/1 or true/false)

View on GitHub (pinned to 5e758547a8)