iflytek/astron-agent · error · ValueError

URL is required for ifly or ifly-v2

Error message

URL is required for ifly or ifly-v2

What it means

Model-level validator for the code-execution config requires a non-empty url when exec_type is 'ifly' or 'ifly-v2' (iFly Spark execution backends). Those exec types route to an external endpoint, so running without a URL is invalid at startup.

Solutions

  1. Set the url field (e.g. CODE_EXEC_URL env var) to the iFly Spark endpoint address
  2. If you do not have an iFly endpoint, switch exec_type to a non-ifly execution type
  3. Verify the env var actually reaches the process (docker-compose/k8s env wiring)

Example fix

// before
EXEC_TYPE=ifly
# URL not set
// after
EXEC_TYPE=ifly
CODE_EXEC_URL=https://spark-api-open.xf-yun.com/v1
Defensive patterns

Strategy: validation

Validate before calling

if exec_type in ("ifly", "ifly-v2") and not url:
    raise ValueError("URL is required for ifly or ifly-v2")

Try / catch

try:
    AppConfig()
except ValidationError as e:
    logger.error("code-exec config invalid: %s", e)
    sys.exit(2)

Prevention

When it happens

Trigger: Choosing exec_type=ifly or ifly-v2 while leaving the url field / CODE_EXEC_URL env var empty or unset.

Common situations: Switching exec_type from a local mode to ifly without filling in the endpoint; copying a config template with the URL placeholder left blank; env var not propagated into the container.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


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

Appendix: source

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

        """Keep the Pyodide V8 heap limit within a bounded range."""
        if not MIN_CODE_EXEC_MEMORY_LIMIT_MB <= v <= MAX_CODE_EXEC_MEMORY_LIMIT_MB:
            raise ValueError(
                "CODE_EXEC_MEMORY_LIMIT_MB must be between "
                f"{MIN_CODE_EXEC_MEMORY_LIMIT_MB} and "
                f"{MAX_CODE_EXEC_MEMORY_LIMIT_MB} MB"
            )
        return v

    @model_validator(mode="after")
    def validator_url(self) -> "CodeExecutorConfig":
        """
        Validate the URL.

        :return: The validated URL
        """
        if self.exec_type in ["ifly", "ifly-v2"]:
            if not self.url:
                raise ValueError("URL is required for ifly or ifly-v2")
            if bool(self.api_key) != bool(self.api_secret):
                raise ValueError(
                    "Both API key and secret must be provided for ifly authentication, or neither."
                )
        return self


class DatabaseConfig(BaseSettings):
    """
    Database connection configuration.

    Loads MySQL connection parameters from environment variables
    (MYSQL_HOST, MYSQL_PORT, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DB).
    """

    model_config = {"env_prefix": "", "case_sensitive": False}

    host: str = Field(default="", alias="MYSQL_HOST")

View on GitHub (pinned to 5e758547a8)