Closed btbonval closed 9 years ago
called from https://github.com/FinalsClub/karmaworld/blob/master/karmaworld/apps/notes/tasks.py#L55-L56 (that URL is bad, it should be dynamically generated!)
calls to https://github.com/FinalsClub/karmaworld/blob/master/karmaworld/apps/notes/models.py#L305
where self.slug
is null.
I'm guessing Note.slug
has not yet been generated?
Production logs appear to show no errors, although I'm not sure what the None
is all about.
2015-01-13T18:42:02.810833+00:00 app[celerywrapper.1]: [2015-01-13 13:42:02,810: INFO/MainProcess] Got task from broker: tweet_note[9a22d403-bcc4-402c-afdb-080a035d5ab3]
2015-01-13T18:42:06.040772+00:00 app[celerywrapper.1]: [2015-01-13 13:42:06,040: INFO/MainProcess] Task tweet_note[9a22d403-bcc4-402c-afdb-080a035d5ab3] succeeded in 3.12053799629s: None
Note.slug
is not nullable, so it ought to be set to something:
https://github.com/FinalsClub/karmaworld/blob/master/karmaworld/apps/notes/models.py#L68
It looks like the slug is the empty string (the third parameter is u''
). That would be worth checking in this if clause:
https://github.com/FinalsClub/karmaworld/blob/master/karmaworld/apps/notes/models.py#L302
Rather than if self.slug is not None:
, perhaps if self.slug:
would be better. That'll fail against an empty string as desired.
A hack might be to forcibly call note._generate_unique_slug()
prior to calling reverse()
on self.slug
https://github.com/FinalsClub/karmaworld/blob/master/karmaworld/apps/notes/models.py#L149
There is indeed a Note with an empty string slug in the Beta database, and it is part of Reason and Faith in the West.
>>> from karmaworld.apps.notes.models import Note
>>> Note.objects.filter(slug=u'')
[<Note: Note at https://www.filepicker.io/api/file/dtQElzaxTuhfO0qouMsn (from None) (1071)>]
>>> Note.objects.filter(slug=u'')[0].course
<Course: Course Reason and Faith in the West in None
Production has no Notes with an empty slug.
>>> from karmaworld.apps.notes.models import Note
>>> Note.objects.filter(slug=u'')
[]
Fixed Beta's database so that errant note is no longer an exception. Now Beta has no notes with an empty slug.
>>> from karmaworld.apps.notes.models import Note
>>> note = Note.objects.filter(slug=u'')[0]
>>> note.slug
u''
>>> note._generate_unique_slug()
>>> note.slug
u'-4-1-948651'
>>> note.save()
>>> Note.objects.filter(slug=u'')
[]
Seems to be an edge case, probably due to all the hacking on Beta's database engine. This is very likely solved. Closing the ticket. Will reopen if the NoReverseMatch
error reappears in the logs.