{"record":{"id":"2cf4e3af6786f124","repo":"HKUDS/DeepTutor","slug":"interactive-html-failed-validation-validation-er","errorCode":null,"errorMessage":"interactive html failed validation: {validation_error}","messagePattern":"interactive html failed validation: (.+?)","errorType":"exception","errorClass":"GenerationFailure","httpStatus":null,"severity":"error","filePath":"deeptutor/book/blocks/interactive.py","lineNumber":96,"sourceCode":"                language=ctx.language,\n            )\n            analysis = await pipeline.run_analysis(\n                user_input=user_input,\n                history_context=history_context,\n                render_mode=\"html\",\n            )\n            code = await pipeline.run_code_generation(\n                user_input=user_input,\n                history_context=history_context,\n                analysis=analysis,\n            )\n        except Exception as exc:\n            logger.warning(f\"InteractiveGenerator failed: {exc}\", exc_info=True)\n            raise GenerationFailure(f\"interactive generation failed: {exc}\") from exc\n\n        ok, validation_error = validate_visualization(code, \"html\")\n        if not ok:\n            raise GenerationFailure(f\"interactive html failed validation: {validation_error}\")\n\n        return (\n            {\n                \"render_type\": \"html\",\n                \"code\": {\"language\": \"html\", \"content\": code},\n                \"description\": analysis.description,\n                \"chart_type\": analysis.chart_type,\n            },\n            [],\n            {\n                \"review_changed\": False,\n                \"review_notes\": \"Passed local validation.\",\n            },\n        )\n\n\n__all__ = [\"InteractiveGenerator\"]\n","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/book/blocks/interactive.py#L78-L114","documentation":"After InteractiveGenerator returns HTML code, the block validates it with validate_visualization(code, 'html'). If the generated HTML fails validation (syntax/structure rules), GenerationFailure is raised with the specific validation error.","triggerScenarios":"Calling interactive _generate when the generated HTML string fails validate_visualization — e.g. unbalanced tags, script syntax errors, or whatever structural rules the 'html' validator enforces.","commonSituations":"LLM emits truncated HTML due to max-token limits; broken inline <script> JS; validator tightened in a newer version; model too weak for large interactive documents.","solutions":["Read validation_error to find the offending construct in the HTML","Retry, possibly with higher max_tokens so output isn't truncated","Use a stronger model or simplify the requested interactive widget","If persistent, hand-edit or externally supply the HTML"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":"def plausible_html(code: str) -> bool:\n    return bool(code) and code.lstrip().lower().startswith('<!doctype') or '<html' in code.lower()","tryCatchPattern":"try:\n    return await interactive_block.generate(ctx)\nexcept GenerationFailure as exc:\n    if 'failed validation' in str(exc):\n        return await interactive_block.generate(ctx)  # retry once\n    raise","preventionTips":["Raise max_tokens so generated HTML isn't truncated","Use a stronger model for large interactive documents","Validate returned HTML client-side before rendering it in the app"],"tags":["interactive","html","validation","generation"],"backgroundTag":"generated-code-validation-failed","analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}