{"record":{"id":"3a6c8669f7c4abce","repo":"iflytek/astron-agent","slug":"cannot-convert-size-v-r","errorCode":null,"errorMessage":"Cannot convert size: {v!r}","messagePattern":"Cannot convert size: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"core/workflow/configs/app_config.py","lineNumber":51,"sourceCode":"        :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\n    def _get_category(self, category: str) -> Optional[FileCategory]:\n        \"\"\"\n        Get the category by its name.\n\n        :param category: The name of the category","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/workflow/configs/app_config.py#L33-L69","documentation":"parse_size raises ValueError('Cannot convert size: {v!r}') when the value is neither a '*' multiplication expression of integers, a digit string, nor an int/float. This is the final fallback guard for unparseable size configuration values.","triggerScenarios":"Passing a size as a string with units ('100MB'), a float-as-string ('10.5'), a list/dict, or None into a config field parsed by parse_size; nested config value of wrong type from Polaris/local file.","commonSituations":"Operator configures '1GB' or '512 MB' instead of bytes; JSON/YAML file provides a quoted float; environment variable interpolation yields an empty or non-numeric string.","solutions":["Set the size as an integer number of bytes (int or digit-only string), e.g. 1073741824","Use the supported 'N*N*...' multiplication form for readability, e.g. '1024*1024*1024'","Validate the config file/environment value before startup with a regex like ^\\d+(\\*\\d+)*$"],"exampleFix":"// before\nmax_file_size: \"1GB\"\n// after\nmax_file_size: 1073741824","handlingStrategy":"validation","validationCode":"import re\nSIZE_EXPR = re.compile(r\"^\\d+(\\*\\d+)*$\")\nif isinstance(value, str) and not SIZE_EXPR.match(value):\n    raise ValueError(f\"size must be int or 'N*N' expression, got {value!r}\")","typeGuard":null,"tryCatchPattern":"try:\n    limit = parse_size(raw)\nexcept ValueError as e:\n    logger.error(\"unconvertible size config: %s\", e)\n    raise SystemExit(2)","preventionTips":["Use integers (bytes) in config, not human units like '1GB'","Pre-commit/lint check config files against the size regex","Type-annotate size fields and document accepted formats","Validate Polaris/local config values before service start"],"tags":["configuration","parsing","size-limit"],"backgroundTag":"invalid-config-value","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"}