Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search crashing with some search terms #1857

Open
sebix opened this issue Mar 8, 2025 · 3 comments
Open

Search crashing with some search terms #1857

sebix opened this issue Mar 8, 2025 · 3 comments

Comments

@sebix
Copy link
Contributor

sebix commented Mar 8, 2025

On 1b072a1 we experience crashes with some searches

2025-03-08 14:46:52,983 ERROR moin:1744 Exception on /+search [GET]
Traceback (most recent call last):
  File "/home/intevation/source/moin.git-venv-python3/lib/python3.11/site-packages/flask_theme/__init__.py", line 472, in render_theme_tem
    return render_template('_themes/%s/%s' % (theme, template_name),
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git-venv-python3/lib/python3.11/site-packages/flask/templating.py", line 146, in render_template
    template = app.jinja_env.get_or_select_template(template_name_or_list)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git-venv-python3/lib/python3.11/site-packages/jinja2/environment.py", line 1081, in get_or_select_tem
    return self.get_template(template_name_or_list, parent, globals)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git-venv-python3/lib/python3.11/site-packages/jinja2/environment.py", line 1010, in get_template
    return self._load_template(name, globals)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git-venv-python3/lib/python3.11/site-packages/jinja2/environment.py", line 969, in _load_template
    template = self.loader.load(self, name, self.make_globals(globals))
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git-venv-python3/lib/python3.11/site-packages/jinja2/loaders.py", line 575, in load
    raise TemplateNotFound(name)
jinja2.exceptions.TemplateNotFound: _themes/focus/search.html

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/intevation/source/moin.git-venv-python3/lib/python3.11/site-packages/flask/app.py", line 2529, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git-venv-python3/lib/python3.11/site-packages/flask/app.py", line 1825, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git-venv-python3/lib/python3.11/site-packages/flask/app.py", line 1823, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git-venv-python3/lib/python3.11/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git/src/moin/apps/frontend/views.py", line 492, in search
    html = render_template(
           ^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git/src/moin/themes/__init__.py", line 70, in render_template
    return render_theme_template(get_current_theme(), template, **context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git-venv-python3/lib/python3.11/site-packages/flask_theme/__init__.py", line 476, in render_theme_template
    return render_template(template_name, **context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git-venv-python3/lib/python3.11/site-packages/flask/templating.py", line 147, in render_template
    return _render(app, template, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git-venv-python3/lib/python3.11/site-packages/flask/templating.py", line 130, in _render
    rv = template.render(context)
         ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git-venv-python3/lib/python3.11/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/home/intevation/source/moin.git-venv-python3/lib/python3.11/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/home/intevation/source/moin.git/src/moin/templates/search.html", line 13, in top-level template code
    {%- set search_form = None %} {# layout will not show search form in header #}
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git/src/moin/themes/focus/templates/layout.html", line 13, in top-level template code
    {% set credits = snippets.credits() %}
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git/src/moin/templates/layout.html", line 13, in top-level template code
    {% set creditlogos = snippets.creditlogos() %}
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git/src/moin/templates/base.html", line 74, in top-level template code
    {%- block layout %}
  File "/home/intevation/source/moin.git/src/moin/themes/focus/templates/layout.html", line 162, in block 'layout'
    {% block item -%}
  File "/home/intevation/source/moin.git/src/moin/themes/focus/templates/layout.html", line 169, in block 'item'
    {% block content %}
  File "/home/intevation/source/moin.git/src/moin/templates/search.html", line 76, in block 'content'
    {%- include "ajaxsearch.html" %}
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git/src/moin/templates/ajaxsearch.html", line 99, in top-level template code
    {%- if result.highlights('content') %}
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git-venv-python3/lib/python3.11/site-packages/whoosh/searching.py", line 1452, in highlights
    return hliter.highlight_hit(self, fieldname, text=text, top=top,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git-venv-python3/lib/python3.11/site-packages/whoosh/highlight.py", line 904, in highlight_hit
    raise KeyError("Field %r is not stored." % fieldname)
KeyError: "Field 'content' is not stored."

The only triggering search terms I found so far were all part of wiki pages that have sub pages, but I'm not entirely sure this is the (only) necessary condition, as it doesn't crash with all page names.

@sebix
Copy link
Contributor Author

sebix commented Mar 8, 2025

Ah, it looks like the focus theme needs an update to become compatible with the current version?

@sebix sebix closed this as completed Mar 8, 2025
@sebix sebix reopened this Mar 9, 2025
@sebix
Copy link
Contributor Author

sebix commented Mar 9, 2025

Ah, it looks like the theme needs an update to become compatible with the current version?

The crash appears with all themes. Here's the stacktrace for modernized:

2025-03-09 08:26:31,533 ERROR moin.signalling.log:31 "Field 'content' is not stored."
Traceback (most recent call last):
  File "/home/intevation/source/moin.git-venv-python3/lib/python3.11/site-packages/flask_theme/__init__.py", line 472, in render_theme_tem
    return render_template('_themes/%s/%s' % (theme, template_name),
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git-venv-python3/lib/python3.11/site-packages/flask/templating.py", line 146, in render_template
    template = app.jinja_env.get_or_select_template(template_name_or_list)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git-venv-python3/lib/python3.11/site-packages/jinja2/environment.py", line 1081, in get_or_select_tem
    return self.get_template(template_name_or_list, parent, globals)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git-venv-python3/lib/python3.11/site-packages/jinja2/environment.py", line 1010, in get_template
    return self._load_template(name, globals)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git-venv-python3/lib/python3.11/site-packages/jinja2/environment.py", line 969, in _load_template
    template = self.loader.load(self, name, self.make_globals(globals))
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git-venv-python3/lib/python3.11/site-packages/jinja2/loaders.py", line 575, in load
    raise TemplateNotFound(name)
jinja2.exceptions.TemplateNotFound: _themes/modernized/search.html

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/intevation/source/moin.git-venv-python3/lib/python3.11/site-packages/flask/app.py", line 2529, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git-venv-python3/lib/python3.11/site-packages/flask/app.py", line 1825, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git-venv-python3/lib/python3.11/site-packages/flask/app.py", line 1823, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git-venv-python3/lib/python3.11/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git/src/moin/apps/frontend/views.py", line 533, in search
    html = render_template(
           ^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git/src/moin/themes/__init__.py", line 69, in render_template
    return render_theme_template(get_current_theme(), template, **context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git-venv-python3/lib/python3.11/site-packages/flask_theme/__init__.py", line 476, in render_theme_tem
    return render_template(template_name, **context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git-venv-python3/lib/python3.11/site-packages/flask/templating.py", line 147, in render_template
    return _render(app, template, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git-venv-python3/lib/python3.11/site-packages/flask/templating.py", line 130, in _render
    rv = template.render(context)
         ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git-venv-python3/lib/python3.11/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/home/intevation/source/moin.git-venv-python3/lib/python3.11/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/home/intevation/source/moin.git/src/moin/templates/search.html", line 13, in top-level template code
    {%- set search_form = None %} {# layout will not show search form in header #}
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git/src/moin/templates/layout.html", line 13, in top-level template code
    {% set creditlogos = snippets.creditlogos() %}
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git/src/moin/templates/base.html", line 74, in top-level template code
    {%- block layout %}
  File "/home/intevation/source/moin.git/src/moin/templates/layout.html", line 56, in block 'layout'
    {% block item -%}
  File "/home/intevation/source/moin.git/src/moin/templates/layout.html", line 64, in block 'item'
    {% block content %}
  File "/home/intevation/source/moin.git/src/moin/templates/search.html", line 76, in block 'content'
    {%- include "ajaxsearch.html" %}
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git/src/moin/templates/ajaxsearch.html", line 100, in top-level template code
    {%- if result.highlights('content') %}
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git-venv-python3/lib/python3.11/site-packages/whoosh/searching.py", line 1452, in highlights
    return hliter.highlight_hit(self, fieldname, text=text, top=top,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/intevation/source/moin.git-venv-python3/lib/python3.11/site-packages/whoosh/highlight.py", line 904, in highlight_hit
    raise KeyError("Field %r is not stored." % fieldname)
KeyError: "Field 'content' is not stored."

@UlrichB22
Copy link
Collaborator

Cannot reproduce the error. Can you check your index and run e.g.

moin index-dump --truncate > index-dump.out
grep -w "^name" index-dump.out | wc -l
grep -w "^content" index-dump.out | wc -l

Usually both results should be the same. However, according to the traceback, there seems to be an item in the index without content.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants