openlibhums / janeway

A web-based platform for publishing journals, preprints, conference proceedings, and books
https://janeway.systems/
GNU Affero General Public License v3.0
177 stars 65 forks source link

TypeError: invalid file: None #653

Closed mauromsl closed 5 years ago

mauromsl commented 5 years ago

It looks like self_article_path() can return None: https://github.com/BirkbeckCTP/janeway/blob/c80dba661a50bf3220fa63b5e2eaad2c6678821d/src/core/models.py#L628-L630 Which triggers a TypeError being raised here: https://github.com/BirkbeckCTP/janeway/blob/c80dba661a50bf3220fa63b5e2eaad2c6678821d/src/core/models.py#L659

ajrbyers commented 5 years ago

@mauromsl there should be no case where a file does not have an article_id. I think we should make the article_id field not null and not blank.

>>> files = models.File.objects.filter(article_id__isnull=True)
>>> files.count()
0

Someone has gone into admin and deleted the article ID for that file...

mauromsl commented 5 years ago

But your query returned a count of zero, if what you are saying is what happened, shouldn't the count have returned (at least) 1, for the file that triggered the error?

ajrbyers commented 5 years ago

That count was from my copy of the DB. Will look at adding a RunPython migration to handle any with missing PKs.