{"record":{"id":"8f3de7893242f34b","repo":"ATH-MaaS/Pixelle-Video","slug":"invalid-size-format-in-path-template-path-dire","errorCode":null,"errorMessage":"Invalid size format in path: {template_path}. Directory name should be 'WIDTHxHEIGHT' (e.g., '1080x1920')","messagePattern":"Invalid size format in path: (.+?)\\. Directory name should be 'WIDTHxHEIGHT' \\(e\\.g\\., '1080x1920'\\)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"pixelle_video/utils/template_util.py","lineNumber":68,"sourceCode":"        >>> parse_template_size(\"1920x1080/modern.html\")\n        (1920, 1080)\n    \"\"\"\n    path = Path(template_path)\n    \n    # Get parent directory name (should be like \"1080x1920\")\n    dir_name = path.parent.name\n    \n    # Special case: if parent is \"templates\", go up one more level\n    if dir_name == \"templates\":\n        # This shouldn't happen in new structure, but handle it\n        raise ValueError(\n            f\"Invalid template path format: {template_path}. \"\n            f\"Expected format: 'WIDTHxHEIGHT/template.html' or 'templates/WIDTHxHEIGHT/template.html'\"\n        )\n    \n    # 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'). \"","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/ATH-MaaS/Pixelle-Video/blob/848b054e4fae40dabc62ec58e960b573e83793ac/pixelle_video/utils/template_util.py#L50-L86","documentation":"parse_template_size requires the template's parent directory name to contain 'x' so it can split into WIDTH and HEIGHT. If the directory name has no 'x' (e.g. 'default', 'mobile', 'hd'), it raises ValueError explaining the directory must be named 'WIDTHxHEIGHT'.","triggerScenarios":"A template path whose immediate parent directory is not a resolution folder — e.g. 'templates/hd/default.html', '1080p/default.html', or the file placed directly in a named directory rather than a WxH one — passed through render_frame, __init__, render_single_output, or render_style_config.","commonSituations":"Users naming template folders semantically ('portrait', '4k') instead of by pixel size; creating custom templates in a new folder without following the WxH convention; typos like '1080*1920' or '1080-1920'.","solutions":["Rename the template directory to the 'WIDTHxHEIGHT' form, e.g. '1080x1920'.","Replace non-'x' separators ('p', '-', '*', spaces) with 'x': '1920x1080'.","Build paths via get_template_full_path(size, template_name) so the convention is enforced for you.","Verify the parent directory of the exact .html file you pass is the resolution folder, not a grouping folder."],"exampleFix":"// before\nparse_template_size(\"templates/hd/default.html\")\n// after\nparse_template_size(\"templates/1920x1080/default.html\")","handlingStrategy":"validation","validationCode":"import re\nfrom pathlib import Path\n\ndef dir_is_wxh(template_path: str) -> bool:\n    return bool(re.fullmatch(r\"\\d+x\\d+\", Path(template_path).parent.name))","typeGuard":"def extract_size_dir(template_path: str):\n    name = Path(template_path).parent.name\n    if 'x' in name:\n        w, _, h = name.partition('x')\n        if w.isdigit() and h.isdigit():\n            return (int(w), int(h))\n    return None","tryCatchPattern":"try:\n    w, h = parse_template_size(template_path)\nexcept ValueError:\n    logger.error(\"Template dir must be WIDTHxHEIGHT, got %r\", Path(template_path).parent.name)\n    raise","preventionTips":["Name template folders strictly 'WIDTHxHEIGHT' (e.g. 1080x1920), never 'hd'/'4k'/'portrait'","Use 'x' as the only separator; avoid '-', '*', 'p'","Generate template directories from a size constant so names stay consistent","Lint the templates tree at startup for non-conforming directory names"],"tags":["path-format","validation","templates"],"backgroundTag":"invalid-path-format","analyzedSha":"848b054e4fae40dabc62ec58e960b573e83793ac","analyzedAt":"2026-08-30T03:24:41.468Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}