User enters very large comic number (i.e. many digits)
The bot requests comic from xkcd.com
xkcd.com returns 503 response because of large url
response is not None and neither is response.status_code 404, so the bot falsely assumes response contains json data
The bot tries to access json data and an exception is thrown on statement config = response.json()
Exception is caught by try/except block and execution continues so the comment is basically skipped
(note that as of lately I wasn't able to reproduce the issue. xkcd.com seems to return 404 now even when the url is very large, but this could be temporary. Nevertheless, these changes should help avoid any issues with other status codes that might be returned.)
Changes:
Truncated comment body down to 10k characters
(this is not the cause of the issue but it could solve similar problems)
Modified if/else block that checked for a None or 404 response to now check for None, or !200 before accessing json data
This way config = response.json() will only be run when response is 200
Modified the functions that match comic ids to only return integers.
This way comic_ids will only contain integers.
I'm still testing and looking into any changes that need to be done to the test cases.
Issue reproduction / explanation:
response
is not None and neither isresponse.status_code
404, so the bot falsely assumes response contains json dataconfig = response.json()
try/except
block and execution continues so the comment is basically skipped(note that as of lately I wasn't able to reproduce the issue. xkcd.com seems to return 404 now even when the url is very large, but this could be temporary. Nevertheless, these changes should help avoid any issues with other status codes that might be returned.)
Changes:
Truncated comment body down to 10k characters (this is not the cause of the issue but it could solve similar problems)
Modified
if/else
block that checked for a None or 404 response to now check for None, or !200 before accessing json data This wayconfig = response.json()
will only be run when response is 200Modified the functions that match comic ids to only return integers. This way
comic_ids
will only contain integers.I'm still testing and looking into any changes that need to be done to the test cases.