digitalmethodsinitiative / 4cat

The 4CAT Capture and Analysis Toolkit provides modular data capture & analysis for a variety of social media platforms.
Other
241 stars 58 forks source link

500 errors caused by processor option #345

Open dale-wahl opened 1 year ago

dale-wahl commented 1 year ago

Describe the bug I have seen this before but cannot recall how it was "fixed". I may have something to do with markdown versions. I see that we have both markdown and markdown2 libraries and swear I removed one (but that could have been in a branch possibly where I was seeing this).

File "/usr/src/app/webtool/templates/result.html", line 7, in block 'body'
    {% include "result-details.html" %}
  File "/usr/src/app/webtool/templates/result-details.html", line 167, in top-level template code
    {% include "processor-details.html" %}
  File "/usr/src/app/webtool/templates/processor-details.html", line 73, in top-level template code
    {% include "components/processor-option.html" %}
  File "/usr/src/app/webtool/templates/components/processor-option.html", line 7, in top-level template code
    {{ option_settings.help|markdown|safe }}
  File "/usr/src/app/webtool/lib/template_filters.py", line 107, in _jinja2_filter_markdown
    val = markdown.markdown(text)
  File "/opt/venv/lib/python3.8/site-packages/markdown/core.py", line 391, in markdown
    return md.convert(text)
  File "/opt/venv/lib/python3.8/site-packages/markdown/core.py", line 252, in convert
    if not source.strip():
jinja2.exceptions.UndefinedError: 'tuple object' has no attribute 'help'

This line seems to be the culprit (or possibly a weird datasource option) Changing it from {{ option_settings.help|markdown|safe }} to {{ option_settings.help }} causes the problem to go away, but I'm not sure what is happening.

dale-wahl commented 1 year ago

Apparently it isn't the removal of |markdown|safe, but instead it is a possibly random error. Reloading the page can cause the issue to go away (or occur).

dale-wahl commented 1 year ago
{% if option_settings is mapping %}
    {{ option_settings.help|markdown|safe }}
{% endif %}

Don't know why it's happening, but this will stop it from happening...

Immediately before option_settings.help is called, option_settings.type is successful so I'm not convinced option_settings is in fact a tuple until markdown does something to it.