Closed SomeMashedPotatoes closed 2 years ago
It seems that it is possible that a conversation might not contain a user message object. I'll have to now check for that before rendering the template to avoid exceptions like this.
Fixed in b3f45ab
Hmm I tried running it again with the new changes and I am getting the same error. My account does have 1 conversation with just 1 message sent on my end.
127.0.0.1 - - [28/Nov/2021 12:50:40] "GET /home HTTP/1.1" 200 -
127.0.0.1 - - [28/Nov/2021 12:50:40] "GET /static/style.css HTTP/1.1" 304 -
[2021-11-28 12:50:42,473] ERROR in app: Exception on /conversations/0 [GET]
Traceback (most recent call last):
File "C:\Users\Juman\Documents\GitHub\kijiji-manager\venv\lib\site-packages\flask\app.py", line 2073, in wsgi_app
response = self.full_dispatch_request()
File "C:\Users\Juman\Documents\GitHub\kijiji-manager\venv\lib\site-packages\flask\app.py", line 1518, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Users\Juman\Documents\GitHub\kijiji-manager\venv\lib\site-packages\flask\app.py", line 1516, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\Juman\Documents\GitHub\kijiji-manager\venv\lib\site-packages\flask\app.py", line 1502, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
File "C:\Users\Juman\Documents\GitHub\kijiji-manager\venv\lib\site-packages\flask_login\utils.py", line 272, in decorated_view
return func(*args, **kwargs)
File "C:\Users\Juman\Documents\GitHub\kijiji-manager\kijiji_manager\views\user.py", line 69, in conversations
return render_template('conversations.html', conversations=data, page=page)
File "C:\Users\Juman\Documents\GitHub\kijiji-manager\venv\lib\site-packages\flask\templating.py", line 147, in render_template
return _render(
File "C:\Users\Juman\Documents\GitHub\kijiji-manager\venv\lib\site-packages\flask\templating.py", line 128, in _render
rv = template.render(context)
File "C:\Users\Juman\Documents\GitHub\kijiji-manager\venv\lib\site-packages\jinja2\environment.py", line 1291, in render
self.environment.handle_exception()
File "C:\Users\Juman\Documents\GitHub\kijiji-manager\venv\lib\site-packages\jinja2\environment.py", line 925, in handle_exception
raise rewrite_traceback_stack(source=source)
File "C:\Users\Juman\Documents\GitHub\kijiji-manager\kijiji_manager\templates\conversations.html", line 1, in top-level template code
{% extends 'layout.html' %}
File "C:\Users\Juman\Documents\GitHub\kijiji-manager\kijiji_manager\templates\layout.html", line 38, in top-level template code
{% block content %}{% endblock %}
File "C:\Users\Juman\Documents\GitHub\kijiji-manager\kijiji_manager\templates\conversations.html", line 42, in block 'content'
{% if item['user:user-message']['user:read'] == 'true' %}
File "C:\Users\Juman\Documents\GitHub\kijiji-manager\venv\lib\site-packages\jinja2\environment.py", line 455, in getitem
return obj[argument]
jinja2.exceptions.UndefinedError: 'str object' has no attribute 'user:user-message'
127.0.0.1 - - [28/Nov/2021 12:50:42] "GET /conversations/0 HTTP/1.1" 500 -
I understand what's happening now. It's because you have just a single conversation with your account. I never encounted this before because I've always had more than one conversation to display.
Try using commit fc66af2 and see if that fixes the bug.
Fixed in commit fc66af2
First off, great work on this project, it was working perfectly up until I went to the conversations tab to try and view my conversations. I know that I have one conversation but I could not even view the page and I instead get a 500 page. Here is the output, looking at the logs it seems like it has to do with the jinja formatting.