Closed glenn-sorrentino closed 7 months ago
This fix addresses the issue where articles with an empty string as their download_size
cause a ValueError
by trying to convert an empty string to an integer. The modification ensures the conversion and formatting only occur when article.download_size
is neither None
nor an empty string.
frontpage/routes.py
# In frontpage/routes.py, within the article view function:
- format_size(int(article.download_size)) if article.download_size is not None else None
+ format_size(int(article.download_size)) if article.download_size not in [None, ''] else None
Description
When attempting to load an article with an empty string as the
download_size
, the application throws aValueError
. This issue occurs due to the application trying to convert an empty string to an integer for formatting the download size.Steps to Reproduce
download_size
.ValueError
and fails to load the article.Expected Behavior
The application should handle empty strings for
download_size
gracefully, allowing the article to load without error.Actual Behavior
The application throws a
ValueError: invalid literal for int() with base 10: ''
and fails to load the article.Possible Fix
Enhance the condition to check not only if
article.download_size
is notNone
but also if it is not an empty string before attempting to convert it to an integer. This could prevent theValueError
.Your Environment