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 @@ -539,18 +539,27 @@ class MarkupRenderer(object): return body, resources captured_errors = {} + error_body = """ +
+

Invalid Notebook!

+

{}

+
+ """ # 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) if captured_errors: error_messages = '
'.join(str(error) for error in captured_errors.values()) - body = f""" -
-

Invalid Notebook!

-

{error_messages}

-
- """ + body = error_body.format(error_messages) else: - body, _ = as_html(notebook) + try: + body, _ = as_html(notebook) + except AttributeError: + try: + nbformat.validate(nbformat.reader.reads(source)) + except nbformat.ValidationError as exc: + body = error_body.format(str(exc)) + else: + raise return body