# HG changeset patch # User Serhii Ilin # Date 2024-01-10 09:52:49 # Node ID 930eac40fadd7eeabd13e4111b169c02f30a766b # Parent 5a32a6f11ae58f5ae9da79e5525606509268f24c fix(jupyter): Catching validation error in order to avoid app crash ic case of formatting issues. Fixes: RCCE-26 diff --git a/rhodecode/lib/markup_renderer.py b/rhodecode/lib/markup_renderer.py --- a/rhodecode/lib/markup_renderer.py +++ b/rhodecode/lib/markup_renderer.py @@ -538,10 +538,20 @@ class MarkupRenderer(object): body = '\n'.join([header, css, js, body]) return body, resources - # TODO: In the event of a newer jupyter notebook version, consider increasing the as_version parameter - notebook = nbformat.reads(source, as_version=4) - (body, resources) = as_html(notebook) - return body + captured_errors = {} + # TODO: In the event of a newer jupyter notebook version, consider increasing the as_version parameter + notebook = nbformat.reads(source, as_version=4, capture_validation_error=captured_errors) + try: + (body, resources) = as_html(notebook) + except AttributeError: + error_messages = '
'.join(str(error) for error in captured_errors.values()) + body = f""" +
+

Invalid Notebook!

+

{error_messages}

+
+ """ + return body class RstTemplateRenderer(object):