Skip to content

Commit 0819fc2

Browse files
authored
fix: return None if remote image length is unavailable (#370)
When this plugin is run on a doc site that also uses the social plugin, fetching remote image data can fail. This results in a crash when building the documentation: File "/path/installs/python/3.11.5/lib/python3.11/site-packages/mkdocs_rss_plugin/util.py", line 608, in get_image img_length = self.get_remote_image_length(image_url=img_url) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/path/installs/python/3.11.5/lib/python3.11/site-packages/mkdocs_rss_plugin/util.py", line 710, in get_remote_image_length return int(img_length) ^^^^^^^^^^^^^^^ TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType' This patch simply returns None if `img_length` is `None.` Closes: #369 Closes: #353
2 parents 257186d + 6ce8a00 commit 0819fc2

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

mkdocs_rss_plugin/util.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@ def __init__(
126126
else:
127127
self.git_is_valid = False
128128
logger.debug(
129-
"Git use is disabled. "
130-
"Only page.meta (YAML frontmatter will be used). "
129+
"Git use is disabled. Only page.meta (YAML frontmatter will be used). "
131130
)
132131

133132
# save git enable/disable status
@@ -707,7 +706,7 @@ def get_remote_image_length(
707706
)
708707
return None
709708

710-
return int(img_length)
709+
return int(img_length) if img_length else None
711710

712711
@staticmethod
713712
def get_site_url(mkdocs_config: MkDocsConfig) -> Optional[str]:

0 commit comments

Comments
 (0)