When upgrading from 2.10.3 to 2.11.0, our async Quart application breaks, HTTP ERROR 500 thrown at user.
here, Candidate is a Quart Model which we loop over to show all Candidates in a Demand. I tried extracting the relevant part of the template:
{% extends "base.html" %}
Paste the template code (ideally a minimal example) that causes the issue
{% for item in candidates %}
<form>
<div class="row result-row">
<div class="col-6">
<h4>
<a href="{{ item.domain }}" target="_blank">{{ item.unified_domain }}</a>
<span class="badge badge-primary" title="Relevance Score. {{ item.score_message }}"><small>{{ item.score|round|int }}</small></span>
</h4>
<div>
{% if item.data['findings'] %}
<span class="badge badge-info" title="Matches"><small>Google Matches ({{ item.data['findings']|length }})</small></span>
{% endif %}
</div>
<div style="overflow: hidden; margin-bottom: 10px;">
{% for finding in item.data['findings'][:1] %}
<b>{{ finding['title'] }}</b>
<br/>
<a target="_blank" href="{{ finding['url'] }}"><small>{{ finding['url'] }}</small></a>
<br/>
<p class="text-muted">{{ finding['description'] }}</p>
{% endfor %}
</div>
</div>
</div>
</form>
{% endfor %}
//templates/simple.html:178: RuntimeWarning: coroutine 'auto_await' was never awaited
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
ERROR:quart.app:Exception on request GET /demand/96
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/quart/app.py", line 1524, in handle_request
return await self.full_dispatch_request(request_context)
File "/usr/local/lib/python3.7/site-packages/quart/app.py", line 1546, in full_dispatch_request
result = await self.handle_user_exception(error)
File "/usr/local/lib/python3.7/site-packages/quart/app.py", line 957, in handle_user_exception
raise error
File "/usr/local/lib/python3.7/site-packages/quart/app.py", line 1544, in full_dispatch_request
result = await self.dispatch_request(request_context)
File "/usr/local/lib/python3.7/site-packages/quart/app.py", line 1592, in dispatch_request
return await handler(**request_.view_args)
File "server.py", line 318, in view_demand
all_score_keywords=[x.strip() for x in demand.score_keywords.split("\n")],
File "/usr/local/lib/python3.7/site-packages/quart/templating.py", line 89, in render_template
return await _render(template, context)
File "/usr/local/lib/python3.7/site-packages/quart/templating.py", line 107, in _render
rendered_template = await template.render_async(context)
File "/usr/local/lib/python3.7/site-packages/jinja2/asyncsupport.py", line 65, in render_async
return self.environment.handle_exception()
File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 832, in handle_exception
reraise(*rewrite_traceback_stack(source=source))
File "/usr/local/lib/python3.7/site-packages/jinja2/_compat.py", line 28, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.7/site-packages/jinja2/asyncsupport.py", line 25, in concat_async
await collect()
File "/usr/local/lib/python3.7/site-packages/jinja2/asyncsupport.py", line 22, in collect
async for event in async_gen:
File "//templates/simple.html", line 1, in top-level template code
{% extends "base.html" %}
File "//templates/base.html", line 43, in top-level template code
{% block content %}
File "//templates/simple.html", line 286, in block "content"
{% for finding in item.data['findings'][:1] %}
TypeError: 'coroutine' object is not subscriptable
Expected Behavior
Rendering was succesfull with Jinja2 2.10.3
Actual Behavior
When upgrading from 2.10.3 to 2.11.0, our async Quart application breaks, HTTP ERROR 500 thrown at user.
Template Code
here, Candidate is a Quart Model which we loop over to show all Candidates in a Demand. I tried extracting the relevant part of the template:
simple.htmlcalled in Quart via
quart.render_templateFull Traceback
Your Environment