ATH-MaaS/Pixelle-Video · error · ValueError
Invalid template path format: {template_path}. Expected form
Error message
Invalid template path format: {template_path}. Expected format: 'WIDTHxHEIGHT/template.html' or 'templates/WIDTHxHEIGHT/template.html' What it means
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.
Source
Thrown at pixelle_video/utils/template_util.py:61
Raises:
ValueError: If template path format is invalid
Examples:
>>> parse_template_size("templates/1080x1920/default.html")
(1080, 1920)
>>> parse_template_size("1920x1080/modern.html")
(1920, 1080)
"""
path = Path(template_path)
# Get parent directory name (should be like "1080x1920")
dir_name = path.parent.name
# Special case: if parent is "templates", go up one more level
if dir_name == "templates":
# This shouldn't happen in new structure, but handle it
raise ValueError(
f"Invalid template path format: {template_path}. "
f"Expected format: 'WIDTHxHEIGHT/template.html' or 'templates/WIDTHxHEIGHT/template.html'"
)
# Parse size from directory name
if 'x' not in dir_name:
raise ValueError(
f"Invalid size format in path: {template_path}. "
f"Directory name should be 'WIDTHxHEIGHT' (e.g., '1080x1920')"
)
try:
width_str, height_str = dir_name.split('x')
width = int(width_str)
height = int(height_str)
# Sanity check
if width < 100 or height < 100 or width > 10000 or height > 10000:View on GitHub (pinned to 848b054e4f)
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.
Example fix
// before
parse_template_size("templates/default.html")
// after
parse_template_size("templates/1080x1920/default.html") # or "1080x1920/default.html" Defensive patterns
Strategy: validation
Validate before calling
import re
from pathlib import Path
def is_valid_template_path(template_path: str) -> bool:
parent = Path(template_path).parent.name
if parent == "templates":
return False
return bool(re.fullmatch(r"\d+x\d+", parent)) Type guard
def parse_size_or_none(template_path: str):
try:
return parse_template_size(template_path)
except ValueError:
return None Try / catch
try:
w, h = parse_template_size(template_path)
except ValueError as e:
raise ConfigError(f"Bad template path {template_path!r}: {e}") from e Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Invalid size format in path: {template_path}. Directory name
- Invalid size dimensions: {width}x{height}
- Failed to parse size from path: {template_path}. Expected fo
- frame_template is required to determine media size
- Progress must be between 0.0 and 1.0, got {self.progress}
AI-assisted analysis of ATH-MaaS/Pixelle-Video@848b054e4f (2026-08-30).
Data as JSON: /api/errors/b91b0e784fc68799.
Report an issue: GitHub.