iflytek/astron-agent · error · ValueError
CODE_EXEC_MEMORY_LIMIT_MB must be between
Error message
CODE_EXEC_MEMORY_LIMIT_MB must be between {MIN_CODE_EXEC_MEMORY_LIMIT_MB} and {MAX_CODE_EXEC_MEMORY_LIMIT_MB} MB What it means
Pydantic field validator rejects a CODE_EXEC_MEMORY_LIMIT_MB outside [MIN_CODE_EXEC_MEMORY_LIMIT_MB, MAX_CODE_EXEC_MEMORY_LIMIT_MB]. This bounds the Pyodide V8 heap limit for sandboxed code execution and fires at settings-load validation time, aborting startup with the invalid value.
Solutions
- Set CODE_EXEC_MEMORY_LIMIT_MB to an integer inside the supported range (see MIN_/MAX_CODE_EXEC_MEMORY_LIMIT_MB in the config module)
- If a larger heap is genuinely required, adjust MAX_CODE_EXEC_MEMORY_LIMIT_MB in code after capacity planning, not via env
- Fix unit conversions (e.g. 2GB -> 2048)
- Remove the variable to fall back to the default instead of forcing 0
Example fix
// before CODE_EXEC_MEMORY_LIMIT_MB=10240 // after CODE_EXEC_MEMORY_LIMIT_MB=1024
Defensive patterns
Strategy: validation
Validate before calling
MIN_M, MAX_M = 64, 8192 # mirror config module values
v = int(os.getenv("CODE_EXEC_MEMORY_LIMIT_MB", "512"))
if not MIN_M <= v <= MAX_M:
raise ValueError(f"CODE_EXEC_MEMORY_LIMIT_MB must be between {MIN_M} and {MAX_M} MB") Try / catch
try:
AppConfig()
except ValidationError as e:
logger.error("invalid CODE_EXEC_MEMORY_LIMIT_MB: %s", e)
sys.exit(2) Prevention
- Document MB units in variable naming/comments
- Do not attempt to disable the heap cap via extreme values
- Check container memory limits are consistent with this value
When it happens
Trigger: Setting CODE_EXEC_MEMORY_LIMIT_MB env var (or the memory_limit_mb field) below the minimum or above the maximum: 0, negative numbers, or extremely large values attempting to disable the heap cap.
Common situations: Operators raising the memory limit for heavy user code and exceeding the hard ceiling; unit confusion (bytes/GB vs MB); empty env var parsed as 0 in container deployments.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- CODE_EXEC_TIMEOUT_SEC must be between
- S3_PRESIGN_ERROR
- ragflow_ext is only allowed when ragType='Ragflow-RAG', got…
- Invalid group: . Valid options
- audio_data cannot be empty
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/a7c72b960ae0c65b.
Report an issue: GitHub.
Appendix: source
Thrown at core/workflow/configs/app_config.py:304
api_secret: str = Field(default="", alias="CODE_EXEC_API_SECRET")
@field_validator("timeout")
@classmethod
def validate_timeout(cls, v: int) -> int:
"""Keep code execution timeouts within the supported safe range."""
if not MIN_CODE_EXEC_TIMEOUT_SEC <= v <= MAX_CODE_EXEC_TIMEOUT_SEC:
raise ValueError(
"CODE_EXEC_TIMEOUT_SEC must be between "
f"{MIN_CODE_EXEC_TIMEOUT_SEC} and {MAX_CODE_EXEC_TIMEOUT_SEC} seconds"
)
return v
@field_validator("memory_limit_mb")
@classmethod
def validate_memory_limit_mb(cls, v: int) -> int:
"""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(View on GitHub (pinned to 5e758547a8)