{"record":{"id":"4a4885967675e431","repo":"ATH-MaaS/Pixelle-Video","slug":"html-rendering-failed-type-e-name-e","errorCode":null,"errorMessage":"HTML rendering failed: {type(e).__name__}: {e}","messagePattern":"HTML rendering failed: (.+?): (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"pixelle_video/services/frame_html.py","lineNumber":474,"sourceCode":"                # local file:// image references are loaded under the same origin.\n                fd, tmp_html_path = tempfile.mkstemp(suffix='.html', prefix='pv_frame_')\n                with os.fdopen(fd, 'w', encoding='utf-8') as f:\n                    f.write(html)\n                \n                await page.goto(Path(tmp_html_path).as_uri(), wait_until='networkidle')\n                await page.screenshot(path=output_path, type='png', omit_background=True)\n            finally:\n                if page:\n                    await page.close()\n                if tmp_html_path and os.path.exists(tmp_html_path):\n                    os.unlink(tmp_html_path)\n            \n            logger.info(f\"Frame generated: {output_path}\")\n            return output_path\n            \n        except Exception as e:\n            logger.exception(\"Failed to render HTML template\")\n            raise RuntimeError(\n                f\"HTML rendering failed: {type(e).__name__}: {e}\"\n            ) from e\n","sourceCodeStart":456,"sourceCodeEnd":477,"githubUrl":"https://github.com/ATH-MaaS/Pixelle-Video/blob/848b054e4fae40dabc62ec58e960b573e83793ac/pixelle_video/services/frame_html.py#L456-L477","documentation":"generate_frame wraps its entire HTML-template rendering pipeline in a broad try/except; any exception (browser/playwright launch failure, template syntax error, missing asset, network fetch for images, etc.) is re-raised as RuntimeError with the original exception class name and message chained via `from e`. The underlying cause is preserved in __cause__ and logged with logger.exception.","triggerScenarios":"Any exception raised inside generate_frame (called from render_frame, _compose_frame_html, render_style_config): headless browser not installed/launchable, template file unreadable, invalid CSS/HTML causing renderer error, output directory not writable, or FileNotFoundError 105 bubbling up from _load_template.","commonSituations":"Playwright/Chromium not installed in a fresh environment ('Executable doesn't exist'); missing system fonts or assets referenced by the template; rendering in a container lacking sandbox flags; disk-full or permission-denied on output_path.","solutions":["Read the chained cause (e.__cause__) or the logged 'Failed to render HTML template' traceback to identify the real exception type.","If the cause is a browser launch error, run the install step (e.g. `playwright install chromium`) or install required system libraries.","Verify output_path's parent directory exists and is writable before calling generate_frame.","Validate the template and referenced assets (fonts, images) exist and the HTML/CSS is well-formed.","Catch RuntimeError around generate_frame and implement a fallback (e.g. plain-color frame) if rendering is optional."],"exampleFix":"// before\noutput = renderer.generate_frame(template, data, output_path)  # crashes on any inner error\n\n// after\ntry:\n    output = renderer.generate_frame(template, data, output_path)\nexcept RuntimeError as e:\n    logger.error(\"frame render failed: %r\", e.__cause__)\n    output = fallback_plain_frame(data, output_path)","handlingStrategy":"try-catch","validationCode":"import os\nassert os.path.isdir(os.path.dirname(output_path) or \".\"), \"output dir missing\"\nassert Path(template_path).is_file(), \"template missing\"\n# plus: ensure playwright browser installed once at startup\n# from playwright.sync_api import sync_playwright\n# with sync_playwright() as p: p.chromium.launch()","typeGuard":null,"tryCatchPattern":"try:\n    out = renderer.generate_frame(template, data, output_path)\nexcept RuntimeError as e:\n    cause = e.__cause__\n    logger.error(\"render failed: %s: %s\", type(cause).__name__, cause)\n    if isinstance(cause, FileNotFoundError):\n        ...  # template/asset missing path\n    else:\n        ...  # fallback frame or re-raise","preventionTips":["Install and pin the headless browser in your environment/image as part of setup.","Pre-create and verify the output directory before rendering.","Keep templates and referenced assets (fonts, images) validated at startup.","Always inspect e.__cause__ rather than the generic RuntimeError message."],"tags":["rendering","runtime-error","wrapping","python"],"backgroundTag":"html-render-failed","analyzedSha":"848b054e4fae40dabc62ec58e960b573e83793ac","analyzedAt":"2026-08-30T03:24:41.468Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}