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

Forum, markread: Raise 404, if forum-slug is not found #1220

Merged
merged 1 commit into from
Jun 19, 2021

Conversation

chris34
Copy link
Member

@chris34 chris34 commented May 6, 2021

Before the fix, one of the new added tests failed

$ python manage.py test tests.apps.forum.test_views.TestMarkRead
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
...E
======================================================================
ERROR: test_no_existing_forum (tests.apps.forum.test_views.TestMarkRead)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/chris/Dev/inyoka/tests/apps/forum/test_views.py", line 1565, in test_no_existing_forum
    response = self.client.get(url, follow=True)
[....]
  File "/home/chris/Dev/inyoka/inyoka/forum/views.py", line 1556, in markread
    forum = Forum.objects.get(slug=slug)
  File "/home/chris/Dev/inyoka/inyoka/forum/models.py", line 105, in get
    forum = self.get_cached(ident)
  File "/home/chris/Dev/inyoka/inyoka/forum/models.py", line 145, in get_cached
    forum = super(ForumManager, self).get(slug=slug)
  File "/home/chris/Dev/inyoka/venv3.5.2/lib/python3.5/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/home/chris/Dev/inyoka/venv3.5.2/lib/python3.5/site-packages/django/db/models/query.py", line 380, in get
    self.model._meta.object_name
inyoka.forum.models.DoesNotExist: Forum matching query does not exist.

----------------------------------------------------------------------
Ran 4 tests in 0.554s

found by @KaiserBarbarossa in the wild.

Before the fix, one of the new added tests failed

python manage.py test tests.apps.forum.test_views.TestMarkRead
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
...E
======================================================================
ERROR: test_no_existing_forum (tests.apps.forum.test_views.TestMarkRead)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/chris/Dev/inyoka/tests/apps/forum/test_views.py", line 1565, in test_no_existing_forum
    response = self.client.get(url, follow=True)
[....]
  File "/home/chris/Dev/inyoka/inyoka/forum/views.py", line 1556, in markread
    forum = Forum.objects.get(slug=slug)
  File "/home/chris/Dev/inyoka/inyoka/forum/models.py", line 105, in get
    forum = self.get_cached(ident)
  File "/home/chris/Dev/inyoka/inyoka/forum/models.py", line 145, in get_cached
    forum = super(ForumManager, self).get(slug=slug)
  File "/home/chris/Dev/inyoka/venv3.5.2/lib/python3.5/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/home/chris/Dev/inyoka/venv3.5.2/lib/python3.5/site-packages/django/db/models/query.py", line 380, in get
    self.model._meta.object_name
inyoka.forum.models.DoesNotExist: Forum matching query does not exist.

----------------------------------------------------------------------
Ran 4 tests in 0.554s
@sebix
Copy link
Member

sebix commented May 23, 2021

I can reproduce the error on forum.ubuntuusers.de, but on staging I get redirected to http://forum.ubuntuusers.local:8080/, without a 500

@chris34
Copy link
Member Author

chris34 commented Jun 3, 2021

but on staging I get redirected to http://forum.ubuntuusers.local:8080/, without a 500

Interestingly, it got an mail from sentry on 2021-05-23: STAGING-2S - DoesNotExist: Forum matching query does not exist.. Was that you or someone else? At the moment i take this as a sign that it was reproduceable on staging, too. :)

@sebix
Copy link
Member

sebix commented Jun 3, 2021

Sorry, I meant the staging branch (locally), not the staging instance.

@chris34
Copy link
Member Author

chris34 commented Jun 3, 2021

Sorry, I meant the staging branch (locally), not the staging instance.

Are you logged in locally? If not, you will test

inyoka/inyoka/forum/views.py

Lines 1552 to 1554 in 221eb15

if user.is_anonymous:
messages.info(request, _('Please login to mark posts as read.'))
return HttpResponseRedirect(href('forum'))
which redirects to http://forum.ubuntuusers.local:8080/, too.

Thus to reproduce, login and visit manually a URL like http://forum.ubuntuusers.local:8080/forum/no_existing_forum123456/markread/.

@sebix
Copy link
Member

sebix commented Jun 18, 2021

Ahh!

Copy link
Member

@sebix sebix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works for me as intended

@chris34 chris34 merged commit 9bd0a3f into inyokaproject:staging Jun 19, 2021
@chris34 chris34 deleted the 404-markread branch June 19, 2021 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants