{"record":{"id":"788ed911af549bce","repo":"ATH-MaaS/Pixelle-Video","slug":"failed-to-parse-size-from-path-template-path-e","errorCode":null,"errorMessage":"Failed to parse size from path: {template_path}. Expected format: 'WIDTHxHEIGHT/template.html' (e.g., '1080x1920/default.html'). Error: {e}","messagePattern":"Failed to parse size from path: (.+?)\\. Expected format: 'WIDTHxHEIGHT/template\\.html' \\(e\\.g\\., '1080x1920/default\\.html'\\)\\. Error: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"pixelle_video/utils/template_util.py","lineNumber":84,"sourceCode":"    # Parse size from directory name\n    if 'x' not in dir_name:\n        raise ValueError(\n            f\"Invalid size format in path: {template_path}. \"\n            f\"Directory name should be 'WIDTHxHEIGHT' (e.g., '1080x1920')\"\n        )\n    \n    try:\n        width_str, height_str = dir_name.split('x')\n        width = int(width_str)\n        height = int(height_str)\n        \n        # Sanity check\n        if width < 100 or height < 100 or width > 10000 or height > 10000:\n            raise ValueError(f\"Invalid size dimensions: {width}x{height}\")\n        \n        return (width, height)\n    except ValueError as e:\n        raise ValueError(\n            f\"Failed to parse size from path: {template_path}. \"\n            f\"Expected format: 'WIDTHxHEIGHT/template.html' (e.g., '1080x1920/default.html'). \"\n            f\"Error: {e}\"\n        )\n\n\ndef list_available_sizes() -> List[str]:\n    \"\"\"\n    List all available video sizes (merged from templates/ and data/templates/)\n    \n    Returns:\n        List of size strings like [\"1080x1920\", \"1920x1080\", \"1080x1080\"]\n    \n    Examples:\n        >>> list_available_sizes()\n        ['1080x1920', '1920x1080', '1080x1080']\n    \"\"\"\n    # Use new resource API to merge default and custom directories","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/ATH-MaaS/Pixelle-Video/blob/848b054e4fae40dabc62ec58e960b573e83793ac/pixelle_video/utils/template_util.py#L66-L102","documentation":"The int(width_str)/int(height_str) conversions and the bounds check inside parse_template_size run in a try block; any ValueError they raise is caught and re-raised as ValueError('Failed to parse size from path: ... Error: ...') with the original message appended. It means the directory name looked like WxH but the halves were not clean integers (or the bounds check tripped).","triggerScenarios":"Directory names like '1080x1920px', '10 80x1920', '1080x1_920', or '1080x' where int() fails on one side; also the bounds-check ValueError from entry 147 gets wrapped by this message.","commonSituations":"Units or suffixes in folder names ('1920pxx1080px'); thousands separators or underscores in dimensions; localized digit characters; accidentally doubling this error with 'Invalid size dimensions' when bounds fail.","solutions":["Rename the directory so both sides are plain integers: '1080x1920'.","Strip unit suffixes/whitespace/separators from the directory name.","Read the appended 'Error:' text to see the underlying cause (int parse failure vs dimension bounds).","Normalize the path programmatically (regex ^\\d+x\\d+$) before calling the renderer."],"exampleFix":"// before\ntemplates/1080x1920px/default.html\n// after\ntemplates/1080x1920/default.html","handlingStrategy":"validation","validationCode":"import re\nfrom pathlib import Path\n\nWxH_RE = re.compile(r\"^(\\d{3,5})x(\\d{3,5})$\")\n\ndef dir_parses_as_ints(template_path: str) -> bool:\n    return bool(WxH_RE.fullmatch(Path(template_path).parent.name))","typeGuard":"def try_parse_size(template_path: str):\n    m = WxH_RE.fullmatch(Path(template_path).parent.name)\n    if not m:\n        return None\n    w, h = int(m.group(1)), int(m.group(2))\n    return (w, h) if 100 <= w <= 10000 and 100 <= h <= 10000 else None","tryCatchPattern":"try:\n    w, h = parse_template_size(template_path)\nexcept ValueError as e:\n    logger.error(\"Size parse failed for %s: %s\", template_path, e)  # underlying cause in 'Error:' suffix\n    raise","preventionTips":["Use bare integers in directory names — no 'px', spaces, underscores, or separators","Regex-validate directory names as ^\\d+x\\d+$ before use","Read the wrapped 'Error:' detail to distinguish int-parse failures from bounds failures","Standardize directory creation through a helper that formats sizes"],"tags":["validation","path-format","integer-parsing"],"backgroundTag":"invalid-path-format","analyzedSha":"848b054e4fae40dabc62ec58e960b573e83793ac","analyzedAt":"2026-08-30T03:24:41.468Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}