simonw/django-sql-dashboard

500 error from markdown if it tries to render a null value

simonw opened this issue · 1 comments

Full traceback:

AttributeError: 'NoneType' object has no attribute 'strip'
  File "django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "django/contrib/auth/decorators.py", line 21, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "django_sql_dashboard/views.py", line 116, in dashboard_index
    return _dashboard_index(
  File "django_sql_dashboard/views.py", line 327, in _dashboard_index
    response = render(
  File "django/shortcuts.py", line 19, in render
    content = loader.render_to_string(template_name, context, request, using=using)
  File "django/template/loader.py", line 62, in render_to_string
    return template.render(context, request)
  File "django/template/backends/django.py", line 61, in render
    return self.template.render(context)
  File "django/template/base.py", line 170, in render
    return self._render(context)
  File "django/template/base.py", line 162, in _render
    return self.nodelist.render(context)
  File "django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "django/template/loader_tags.py", line 150, in render
    return compiled_parent._render(context)
  File "django/template/base.py", line 162, in _render
    return self.nodelist.render(context)
  File "django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "django/template/loader_tags.py", line 150, in render
    return compiled_parent._render(context)
  File "django/template/base.py", line 162, in _render
    return self.nodelist.render(context)
  File "django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "django/template/loader_tags.py", line 62, in render
    result = block.nodelist.render(context)
  File "django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "django/template/defaulttags.py", line 211, in render
    nodelist.append(node.render_annotated(context))
  File "django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "django/template/loader_tags.py", line 195, in render
    return template.render(context)
  File "django/template/base.py", line 172, in render
    return self._render(context)
  File "django/template/base.py", line 162, in _render
    return self.nodelist.render(context)
  File "django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "django/template/loader_tags.py", line 150, in render
    return compiled_parent._render(context)
  File "django/template/base.py", line 162, in _render
    return self.nodelist.render(context)
  File "django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "django/template/loader_tags.py", line 62, in render
    result = block.nodelist.render(context)
  File "django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "django/template/defaulttags.py", line 211, in render
    nodelist.append(node.render_annotated(context))
  File "django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "django/template/base.py", line 988, in render
    output = self.filter_expression.resolve(context)
  File "django/template/base.py", line 698, in resolve
    new_obj = func(obj, *arg_vals)
  File "django_sql_dashboard/templatetags/django_sql_dashboard.py", line 61, in sql_dashboard_markdown
    markdown.markdown(
  File "markdown/core.py", line 387, in markdown
    return md.convert(text)
  File "markdown/core.py", line 248, in convert
    if not source.strip():

Easiest way to reproduce this is select null as markdown.