{"record":{"id":"a7249b4be6d1bc33","repo":"iflytek/astron-agent","slug":"invalid-size-expression-v","errorCode":null,"errorMessage":"Invalid size expression: {v}","messagePattern":"Invalid size expression: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"core/workflow/configs/app_config.py","lineNumber":46,"sourceCode":"    @classmethod\n    def parse_size(cls, v: Any) -> int:\n        \"\"\"\n        Parse the size of the file category.\n\n        :param v: The size of the file category\n        :return: The size of the file category\n        :raises ValueError: If the size of the file category is invalid\n        \"\"\"\n        if isinstance(v, str):\n            if \"*\" in v:\n                try:\n                    parts = [int(x) for x in v.split(\"*\")]\n                    result = 1\n                    for p in parts:\n                        result *= p\n                    return result\n                except ValueError:\n                    raise ValueError(f\"Invalid size expression: {v}\")\n            if v.isdigit():\n                return int(v)\n        if isinstance(v, (int, float)):\n            return int(v)\n        raise ValueError(f\"Cannot convert size: {v!r}\")\n\n\nclass FileConfig(BaseSettings):\n    \"\"\"\n    File configuration model.\n\n    This model represents the file configuration with its categories.\n    :param categories: The categories of the file configuration\n    \"\"\"\n\n    model_config = {\"env_prefix\": \"\", \"case_sensitive\": False}\n    categories: List[FileCategory] = Field(default_factory=list, alias=\"FILE_POLICY\")\n","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/workflow/configs/app_config.py#L28-L64","documentation":"parse_size raises ValueError('Invalid size expression: {v}') when a string size looks like a multiplication expression (contains '*') but one or more '*'-separated parts are not valid integers. Used to turn config strings like '512*1024*1024' into byte counts for file size limits.","triggerScenarios":"Config value like '512x1024' or '10 * 1024MB' or '1024**1024' where splitting on '*' yields non-numeric parts; whitespace-embedded or unit-suffixed expressions inside a '*' expression.","commonSituations":"Operator writes '1*1024*1024 MB' or '100*KB' in the size config; YAML unquoted value mangled; copy-paste from docs with units included.","solutions":["Write the size as a pure multiplication of integers, e.g. '512*1024*1024', with no units or spaces","Use a plain integer byte value (e.g. '1073741824') instead of an expression","Quote the value in YAML so it is parsed as a string with the expected format"],"exampleFix":"// before\nfile_max_size: 1024*1024MB\n// after\nfile_max_size: 1024*1024*1024","handlingStrategy":"validation","validationCode":"import re\nSIZE_EXPR = re.compile(r\"^\\d+(\\*\\d+)*$\")\nif not SIZE_EXPR.match(str(value)):\n    raise ValueError(f\"size must be digits or N*N multiplication, got {value!r}\")","typeGuard":null,"tryCatchPattern":"try:\n    limit = parse_size(raw)\nexcept ValueError as e:\n    logger.error(\"bad size expression in config: %s\", e)\n    raise SystemExit(2)","preventionTips":["Express sizes as integer byte values or pure N*N expressions","Never embed units (MB, KB) or spaces inside size expressions","Quote YAML values so they parse as strings in the expected format","Add the size regex to config templates as a comment"],"tags":["configuration","parsing","size-limit"],"backgroundTag":"invalid-argument-format","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}