Cannot edit RSS feeds - [OverflowError: mktime argument out of range] Windows

Report & discuss bugs found in SABnzbd
Forum rules
Help us help you:
  • Are you using the latest stable version of SABnzbd? Downloads page.
  • Tell us what system you run SABnzbd on.
  • Adhere to the forum rules.
  • Do you experience problems during downloading?
    Check your connection in Status and Interface settings window.
    Use Test Server in Config > Servers.
    We will probably ask you to do a test using only basic settings.
  • Do you experience problems during repair or unpacking?
    Enable +Debug logging in the Status and Interface settings window and share the relevant parts of the log here using [ code ] sections.
airguy
Newbie
Newbie
Posts: 31
Joined: December 5th, 2011, 4:45 pm

Cannot edit RSS feeds - [OverflowError: mktime argument out of range] Windows

Post by airguy »

I have 2 RSS feeds that I am unable to edit from the RSS feeds page. Whenever I click on them to edit entries I get this error:

500 Internal Server Error

The server encountered an unexpected condition which prevented it from fulfilling the request.

Traceback (most recent call last):
File "cherrypy\_cprequest.pyo", line 670, in respond
File "cherrypy\lib\encoding.pyo", line 220, in __call__
File "cherrypy\_cpdispatch.pyo", line 60, in __call__
File "sabnzbd\interface.pyo", line 127, in internal_wrap
File "sabnzbd\interface.pyo", line 1773, in index
File "sabnzbd\interface.pyo", line 2576, in GetRssLog
File "sabnzbd\interface.pyo", line 2553, in make_item
OverflowError: mktime argument out of range

Powered by CherryPy 8.1.2

One of the feeds has over approximately 500 entries, is that too many? The feeds I am trying to edit do however continue to function and download new nzb's from the feeds. I am presently running SABnzbd v2.3.8 under windows home server 2011 (Server 2008 r2). I also tried upgrading to 2.3.9. but still happens. I also tried restoring backups of my .sab databases along with the .ini file but still the same.
I have not tried to delete the RSS feed and re-do it. Trying to avoid that if possible. It would take some time.
Any help?

User avatar
safihre
Administrator
Administrator
Posts: 3657
Joined: April 30th, 2015, 7:35 am
Location: Switzerland
Contact:

Re: Cannot edit RSS feeds - Error

Post by safihre »

It seems that there is an invalid date inside the RSS feed you are trying to read. Maybe you can shutdown SABnzbd, go to your SABnzbd Admin directory and remove the rss_data file. This will remove all the history for your feeds.

airguy
Newbie
Newbie
Posts: 31
Joined: December 5th, 2011, 4:45 pm

Re: Cannot edit RSS feeds - Error

Post by airguy »

safihre wrote:
March 12th, 2020, 7:17 am
It seems that there is an invalid date inside the RSS feed you are trying to read. Maybe you can shutdown SABnzbd, go to your SABnzbd Admin directory and remove the rss_data file. This will remove all the history for your feeds.
Well, after shutting down SABnzbd and deleting rss_data.sab, & restarting the program I can enter into and edit the 2 RSS feeds that were the problem. However, the problem returns shortly after, and I have to repeat this process to again edit those 2 feeds. Any other thoughts?

User avatar
sander
Release Testers
Release Testers
Posts: 6977
Joined: January 22nd, 2008, 2:22 pm

Re: Cannot edit RSS feeds - Error

Post by sander »

airguy wrote:
March 11th, 2020, 11:21 am

File "sabnzbd\interface.pyo", line 2576, in GetRssLog
File "sabnzbd\interface.pyo", line 2553, in make_item
OverflowError: mktime argument out of range
First step in analysis:

So https://github.com/sabnzbd/sabnzbd/blob ... e.py#L2553, so

Code: Select all

job['age_ms'] = time.mktime(job['age'].timetuple())


On Windows, you can reproduce "OverflowError: mktime argument out of range" like this:

Code: Select all

Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 21:26:53) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> import time
>>> t = (1956, 3, 2, 0, 0, 0, 0, 0, 0)
>>> ser = time.mktime(t)
Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    ser = time.mktime(t)
OverflowError: mktime argument out of range
>>> 
Cause: date before epoc 0 (1 jan 1970?)


So, combining the above info should lead to a cause. First step: OP, in the RSS, do you see an old or odd date?


Also: On Linux, that same code does not produce an error:

Code: Select all

[email protected]:~$ python
Python 2.7.17 (default, Nov  7 2019, 10:07:09)
[GCC 7.4.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import time
>>> t = (1956, 3, 2, 0, 0, 0, 0, 0, 0)
>>> ser = time.mktime(t)
>>> ser
-436582800.0
>>>

airguy
Newbie
Newbie
Posts: 31
Joined: December 5th, 2011, 4:45 pm

Re: Cannot edit RSS feeds - Error

Post by airguy »

Thanks for the reply but you're a little over my head. I don't code, especially in python. I understand that you are saying there is a variable that is out of range. Are you telling me to look for an odd date in my RSS feeds? I do not see any dates in my entries, unless a wildcard is being misinterpreted as such. I sure would like to solve it. Deleting the rss_data.sab file only lets me enter the page one time. Any edits, or saves will result in the crash listed above in my first post. Then I have to repeat shutting down SABnzbd, deleting the file, and again I can enter the RSS page to see what is there. But again, any changes will result in the crash. I have managed to save the pages in my browser, so I may have to just delete the feeds and use the saved pages to re-enter the data (which will take a lot of time to do 539 entries manually). I will wait to do that hoping I can find an easier solution or understand what you have mentioned above.
Thanks again for the help.

User avatar
sander
Release Testers
Release Testers
Posts: 6977
Joined: January 22nd, 2008, 2:22 pm

Re: Cannot edit RSS feeds - Error

Post by sander »

Can you share the RSS file?

User avatar
sander
Release Testers
Release Testers
Posts: 6977
Joined: January 22nd, 2008, 2:22 pm

Re: Cannot edit RSS feeds - Error

Post by sander »

Ah, I can reproduce with Sab on Windows with this crafted RSS-URL https://www.appelboor.com/dump/rss-mini-1940

Cause: in the RSS is a date "20 jan 1940", which is before Unix Epoch 0, so negative, and gives a traceback on Windows.


EDIT: Ah, also date 20 jan 9999 (https://www.appelboor.com/dump/rss.20jan9999) gives this error.

So SAB-on-Windows is vulnerable for unlikely dates.


500 Internal Server Error
The server encountered an unexpected condition which prevented it from fulfilling the request.

Traceback (most recent call last):
File "site-packages\cherrypy\_cprequest.py", line 638, in respond
File "site-packages\cherrypy\_cprequest.py", line 697, in _do_respond
File "site-packages\cherrypy\lib\encoding.py", line 219, in __call__
File "site-packages\cherrypy\_cpdispatch.py", line 54, in __call__
File "sabnzbd\interface.py", line 121, in internal_wrap
File "sabnzbd\interface.py", line 1688, in index
File "sabnzbd\interface.py", line 2490, in GetRssLog
File "sabnzbd\interface.py", line 2471, in make_item
OverflowError: mktime argument out of range

User avatar
sander
Release Testers
Release Testers
Posts: 6977
Joined: January 22nd, 2008, 2:22 pm

Re: Cannot edit RSS feeds - Error

Post by sander »

Explanation and solution on https://stackoverflow.com/a/2518828 , so:

Code: Select all

from datetime import datetime
epoch = datetime(1970, 1, 1)
t = datetime(1956, 3, 2)
diff = t-epoch
print(int(1000*diff.total_seconds()))
I don't run SABnzbd from source on Windows, so I can't put that code into SAB and test it.

User avatar
sander
Release Testers
Release Testers
Posts: 6977
Joined: January 22nd, 2008, 2:22 pm

Re: Cannot edit RSS feeds - [OverflowError: mktime argument out of range] Windows

Post by sander »

I hacked some code together, and it seems the above is indeed the solution to put in SABnzbd.

Linux: all good, both method yield the same result, so ... compatible!

Code: Select all

[email protected]:~$ python3 tijdje.py
age in seconds since epoch of 2020-01-20 00:00:00
1579478400.0
1579474800.0
age in seconds since epoch of 2002-10-18 00:00:00
1034899200.0
1034892000.0
age in seconds since epoch of 1940-01-20 00:00:00
-945129600.0
-945130800.0
age in seconds since epoch of 9999-01-20 00:00:00
253372406400.0
253372402800.0

Windows:

For normal/recent dates: both good. Far-away dates: proof the new method works, and the old method goes wrong. So ... compatible & bug-fix!

Code: Select all

C:\Downloads>python3 tijdje.py
age in seconds since epoch of 2020-01-20 00:00:00
1579478400.0
1579474800.0
age in seconds since epoch of 2002-10-18 00:00:00
1034899200.0
1034892000.0
age in seconds since epoch of 1940-01-20 00:00:00
-945129600.0
mktime did not work
age in seconds since epoch of 9999-01-20 00:00:00
253372406400.0
mktime did not work


Code: Select all

import time
from datetime import datetime

def showage(mydate):

	print("age in seconds since epoch of", mydate)
	epoch = datetime.utcfromtimestamp(0)
	diff = mydate - epoch
	print(diff.total_seconds())

	try:
		print(time.mktime(mydate.timetuple()))
	except:
		print("mktime did not work")

job = {}

#print("Het is", datetime.fromisoformat('2020-01-20') - datetime.utcfromtimestamp(0))

job['age'] = datetime.fromisoformat('2020-01-20')
showage(job['age'])

job['age'] = datetime.fromisoformat('2002-10-18')
showage(job['age'])

job['age'] = datetime.fromisoformat('1940-01-20')
showage(job['age'])

job['age'] = datetime.fromisoformat('9999-01-20')
showage(job['age'])

User avatar
sander
Release Testers
Release Testers
Posts: 6977
Joined: January 22nd, 2008, 2:22 pm

Re: Cannot edit RSS feeds - [OverflowError: mktime argument out of range] Windows

Post by sander »

@safihre: shall I send a PR for this?
@airguy: in the RSS did you find the strange date (< 1970, or far away in the future)? If so, can you inform your indexer? Which indexer is causing this?

User avatar
safihre
Administrator
Administrator
Posts: 3657
Joined: April 30th, 2015, 7:35 am
Location: Switzerland
Contact:

Re: Cannot edit RSS feeds - [OverflowError: mktime argument out of range] Windows

Post by safihre »

Sounds good!

airguy
Newbie
Newbie
Posts: 31
Joined: December 5th, 2011, 4:45 pm

Re: Cannot edit RSS feeds - [OverflowError: mktime argument out of range] Windows

Post by airguy »

sander wrote:
March 13th, 2020, 1:59 am
@safihre: shall I send a PR for this?
@airguy: in the RSS did you find the strange date (< 1970, or far away in the future)? If so, can you inform your indexer? Which indexer is causing this?
Well, I did find some strange dates in a couple of entries in the RSS feed. I was a little confused, as all I was trying to do was edit my entries in the feed, but apparantly what you are saying is the feed is read when you click on the feed to edit entries. I thought the feed is read when you click on "read feed". Anyhow, that makes sense now.

Here is a few entries from my RSS feed copied from my browser. I see the bad PostDate of 6988. Is this the culprit? There are also other entries in the feed with these dates.
NinjaCentral is the indexer. I am hesitant to paste the indexer url here as I believe it contains my api key information.

NinjaCentral
NinjaCentral Feed

Supergirl.S05E14.720p.HDTV.x264-SVA-Scrambled
Sunday, March 08, 2020, 10:24 PM

ID: 9267a28ac8e23b781845309304a3a469
Name: Supergirl.S05E14.720p.HDTV.x264-SVA-Scrambled
Size: 865.98 MB
Attributes: Category - TV > HD
Groups: alt.binaries.nzb
Poster: [email protected]
PostDate: Wed, 30 Jul 6988 20:30:51 +0000
Password: None

Kims.Convenience.S04E09.Which.Witch.is.Which.720p.iT.WEB-DL.AAC2.0.H.264-KiMCHi-Scrambled
Thursday, March 05, 2020, 11:48 PM

ID: ad3965941322c624a7a57e087145c887
Name: Kims.Convenience.S04E09.Which.Witch.is.Which.720p.iT.WEB-DL.AAC2.0.H.264-KiMCHi-Scrambled
Size: 775.05 MB
Attributes: Category - TV > HD
Groups: alt.binaries.nzb
Poster: [email protected]
PostDate: Mon, 15 Oct 6987 12:55:07 +0000
Password: None

Family.Guy.S14E19.Run.Chris.Run.1080p.AMZN.WEBRip.DD5.1.x264-CasStudio-Scrambled
Thursday, March 12, 2020, 7:40 AM

ID: 566bb67ad05fdb15b237360e523fb102
Name: Family.Guy.S14E19.Run.Chris.Run.1080p.AMZN.WEBRip.DD5.1.x264-CasStudio-Scrambled
Size: 379.78 MB
Attributes: Category - TV > HD
Groups: alt.binaries.nzb
Poster: [email protected]
PostDate: Sat, 13 May 2023 22:17:50 +0000
Password: None

James.Corden.2020.03.11.Emily.Blunt.720p.WEB.x264-XLF
Thursday, March 12, 2020, 6:32 AM

ID: 8c831ac097001009133f55482021a138
Name: James.Corden.2020.03.11.Emily.Blunt.720p.WEB.x264-XLF
Size: 969.99 MB
Attributes: Category - TV > HD
Groups: alt.binaries.nzb
Poster: [email protected]
PostDate: Mon, 06 Jul 2020 05:07:43 +0000 <<<------------ This date is correct, right?
Password: None

I will attempt to contact the admins of the indexer to see if this can be corrected.
Am I correct in assuming you are also going to fix this for windows in future versions of SABnzbd?

User avatar
sander
Release Testers
Release Testers
Posts: 6977
Joined: January 22nd, 2008, 2:22 pm

Re: Cannot edit RSS feeds - [OverflowError: mktime argument out of range] Windows

Post by sander »

PostDate: Wed, 30 Jul 6988 20:30:51 +0000
A post from the future ... ;)

Yup, that date is wrong, and causing the problem with SAB-on-Windows. Can you inform the indexer so that they can correct it? EDIT: I've posted on their forum http://ninjacentral.co.za/forumpost/614

Only on Windows this is now a problem (bugfix will come against SAB-3), not on Linux / OSX / NAS. So if you have such a system around ... ?

Sander

airguy
Newbie
Newbie
Posts: 31
Joined: December 5th, 2011, 4:45 pm

Re: Cannot edit RSS feeds - [OverflowError: mktime argument out of range] Windows

Post by airguy »

sander wrote:
March 13th, 2020, 9:08 am
PostDate: Wed, 30 Jul 6988 20:30:51 +0000
A post from the future ... ;)

Yup, that date is wrong, and causing the problem with SAB-on-Windows. Can you inform the indexer so that they can correct it? EDIT: I've posted on their forum http://ninjacentral.co.za/forumpost/614

Only on Windows this is now a problem (bugfix will come against SAB-3), not on Linux / OSX / NAS. So if you have such a system around ... ?

Sander
Sure appreciate all the help. I hope they fix their RSS soon. I will also look forward to the fix for SAB-3 for windows.
Thank you again, Sander.

User avatar
sander
Release Testers
Release Testers
Posts: 6977
Joined: January 22nd, 2008, 2:22 pm

Re: Cannot edit RSS feeds - [OverflowError: mktime argument out of range] Windows

Post by sander »

@safihre:

PR sent: https://github.com/sabnzbd/sabnzbd/pull/1373

EDIT: tested on SAB3-from-source on Windows with the PR, and it works with https://www.appelboor.com/dump/rss-mini-1940 :)

Image

Post Reply