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):