Errors subscribing a non-existent user. version =< 0.2.3
Closed this issue · 1 comments
evereux commented
When subscribing a non-existent user (i.e. user is not selected from pull down list) the ticket is no longer accessible and results in the following stack-trace:
Traceback (most recent call last):
File "/home/evereux/python/projects/flicket/env/lib/python3.8/site-packages/flask/app.py", line 2464, in __call__
return self.wsgi_app(environ, start_response)
File "/home/evereux/python/projects/flicket/env/lib/python3.8/site-packages/flask/app.py", line 2450, in wsgi_app
response = self.handle_exception(e)
File "/home/evereux/python/projects/flicket/env/lib/python3.8/site-packages/flask/app.py", line 1867, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/evereux/python/projects/flicket/env/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/evereux/python/projects/flicket/env/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/home/evereux/python/projects/flicket/env/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/evereux/python/projects/flicket/env/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/evereux/python/projects/flicket/env/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/evereux/python/projects/flicket/env/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/home/evereux/python/projects/flicket/env/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/evereux/python/projects/flicket/env/lib/python3.8/site-packages/flask_login/utils.py", line 272, in decorated_view
return func(*args, **kwargs)
File "/home/evereux/python/projects/flicket/application/flicket/views/view_ticket.py", line 155, in ticket_view
return render_template('flicket_view.html',
File "/home/evereux/python/projects/flicket/env/lib/python3.8/site-packages/flask/templating.py", line 137, in render_template
return _render(
File "/home/evereux/python/projects/flicket/env/lib/python3.8/site-packages/flask/templating.py", line 120, in _render
rv = template.render(context)
File "/home/evereux/python/projects/flicket/env/lib/python3.8/site-packages/jinja2/environment.py", line 1090, in render
self.environment.handle_exception()
File "/home/evereux/python/projects/flicket/env/lib/python3.8/site-packages/jinja2/environment.py", line 832, in handle_exception
reraise(*rewrite_traceback_stack(source=source))
File "/home/evereux/python/projects/flicket/env/lib/python3.8/site-packages/jinja2/_compat.py", line 28, in reraise
raise value.with_traceback(tb)
File "/home/evereux/python/projects/flicket/application/flicket/templates/flicket_view.html", line 1, in top-level template code
{% extends "flicket_base.html" %}
File "/home/evereux/python/projects/flicket/application/flicket/templates/flicket_base.html", line 54, in top-level template code
{% block content %}{% endblock %}
File "/home/evereux/python/projects/flicket/application/flicket/templates/flicket_view.html", line 129, in block "content"
href="{{ url_for('flicket_bp.unsubscribe_ticket', ticket_id = ticket.id, user_id=s.user.id) }}"
File "/home/evereux/python/projects/flicket/env/lib/python3.8/site-packages/flask/helpers.py", line 357, in url_for
rv = url_adapter.build(
File "/home/evereux/python/projects/flicket/env/lib/python3.8/site-packages/werkzeug/routing.py", line 2177, in build
rv = self._partial_build(endpoint, values, method, append_unknown)
File "/home/evereux/python/projects/flicket/env/lib/python3.8/site-packages/werkzeug/routing.py", line 2054, in _partial_build
rv = self._partial_build(
File "/home/evereux/python/projects/flicket/env/lib/python3.8/site-packages/werkzeug/routing.py", line 2067, in _partial_build
rv = rule.build(values, append_unknown)
File "/home/evereux/python/projects/flicket/env/lib/python3.8/site-packages/werkzeug/routing.py", line 1038, in build
return self._build_unknown(**values)
File "<werkzeug routing>", line 1, in <builder:'/unsubscribe/<int:ticket_id>/<int:user_id>'>
File "/home/evereux/python/projects/flicket/env/lib/python3.8/site-packages/werkzeug/routing.py", line 1257, in to_url
value = self.num_convert(value)
jinja2.exceptions.UndefinedError: 'None' has no attribute 'id'
This is because the form does not validate the existence of the submitted user.
To fix the issue you'll need to delete the rows in the flicket_ticket_subscription
table that has the ticket_id of the broken ticket view and a NULL user_id.
SELECT * FROM `lowlife-flicket`.flicket_ticket_subscription WHERE user_id is NULL;
Also, delete the rows in the table flicket_ticket_action
where action = subscribed and the recipient_id is NULL.
SELECT * FROM `lowlife-flicket`.flicket_ticket_action WHERE action = 'subscribe' and recipient_id is NULL;
This will be fixed for 0.2.4 (released later today).
evereux commented
Closing as issue is fixed.