{"record":{"id":"b91b0e784fc68799","repo":"ATH-MaaS/Pixelle-Video","slug":"invalid-template-path-format-template-path-exp","errorCode":null,"errorMessage":"Invalid template path format: {template_path}. Expected format: 'WIDTHxHEIGHT/template.html' or 'templates/WIDTHxHEIGHT/template.html'","messagePattern":"Invalid template path format: (.+?)\\. Expected format: 'WIDTHxHEIGHT/template\\.html' or 'templates/WIDTHxHEIGHT/template\\.html'","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"pixelle_video/utils/template_util.py","lineNumber":61,"sourceCode":"    \n    Raises:\n        ValueError: If template path format is invalid\n    \n    Examples:\n        >>> parse_template_size(\"templates/1080x1920/default.html\")\n        (1080, 1920)\n        >>> 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:","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/ATH-MaaS/Pixelle-Video/blob/848b054e4fae40dabc62ec58e960b573e83793ac/pixelle_video/utils/template_util.py#L43-L79","documentation":"parse_template_size derives WIDTHxHEIGHT from the parent directory of a template path. If the parent directory is literally 'templates' (i.e. the path does not follow the WIDTHxHEIGHT/template.html layout), it raises ValueError describing the expected format. It guards against passing old-structure or wrong-level paths.","triggerScenarios":"Passing a path like 'templates/default.html' or a path whose parent dir is 'templates' to parse_template_size — typically via render_frame, renderer __init__, render_single_output, or render_style_config configured with a legacy or root-level template path.","commonSituations":"Migrating from an older template layout where files sat directly under templates/; hand-built paths missing the resolution directory; config still pointing at a deprecated path after upgrading the library.","solutions":["Restructure the path to include a resolution directory: 'WIDTHxHEIGHT/template.html' (e.g. '1080x1920/default.html').","Use get_template_full_path(size, name) to build the path instead of hand-constructing it.","If you have a path ending in '/templates/x.html', strip the 'templates' segment and insert the target resolution directory.","Update config/render calls that still reference the old template directory layout."],"exampleFix":"// before\nparse_template_size(\"templates/default.html\")\n// after\nparse_template_size(\"templates/1080x1920/default.html\")  # or \"1080x1920/default.html\"","handlingStrategy":"validation","validationCode":"import re\nfrom pathlib import Path\n\ndef is_valid_template_path(template_path: str) -> bool:\n    parent = Path(template_path).parent.name\n    if parent == \"templates\":\n        return False\n    return bool(re.fullmatch(r\"\\d+x\\d+\", parent))","typeGuard":"def parse_size_or_none(template_path: str):\n    try:\n        return parse_template_size(template_path)\n    except ValueError:\n        return None","tryCatchPattern":"try:\n    w, h = parse_template_size(template_path)\nexcept ValueError as e:\n    raise ConfigError(f\"Bad template path {template_path!r}: {e}\") from e","preventionTips":["Always use get_template_full_path(size, name) instead of hand-built paths","Keep the WIDTHxHEIGHT directory as the immediate parent of the .html file","Migrate legacy templates/ layouts to the WIDTHxHEIGHT structure","Validate template paths in config at startup"],"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"}