egh / ledger-autosync

Synchronize your ledger-cli files with your bank.
GNU General Public License v3.0
273 stars 42 forks source link

ledger-autosync doesn't detect error response #39

Closed 501st-alpha1 closed 6 years ago

501st-alpha1 commented 7 years ago

I ran ledger-autosync just now, and it returned with no output, even though earlier it had given me a list of transactions and I hadn't added all of them to my ledgerfile yet. I enabled debug logging to troubleshoot the issue, and found this:

[snip]
DEBUG:root:---- response ----
DEBUG:root:{'fp': None, 'status': 200, 'will_close': False, 'chunk_left': 'UNKNOWN', 'length': 0, 'strict': 0, 'reason': 'OK', 'version': 11, 'debuglevel': 0, 'msg': <httplib.HTTPMessage instance at 0x7ff9703c0e18>, 'chunked': 0, '_method': u'POST'}
DEBUG:root:OFXHEADER:100
DATA:OFXSGML
VERSION:102
SECURITY:NONE
ENCODING:USASCII
CHARSET:1252
COMPRESSION:NONE
OLDFILEUID:NONE
NEWFILEUID:28a7999be2484c698d601ec9d4aaea3d

<OFX><SIGNONMSGSRSV1><SONRS><STATUS><CODE>2000<SEVERITY>ERROR<MESSAGE>Customer needs an Access Code from Capital One 360 (along with your Customer Number or Saver ID (Username)) in order to pull Capital One 360 info into this tool.</STATUS><DTSERVER>20170830042305.465<LANGUAGE>ENG<DTACCTUP>20170830042305.465<FI><ORG>ING DIRECT<FID>031176110</FI></SONRS></SIGNONMSGSRSV1></OFX>
DEBUG:root:empty account: increasing days ago to 14.
[snip]

This happens several times until the max days is reached.

It appears that ledger-autosync is not catching an error condition reported by the server. I believe this is a bug, and the error message above should be shown to the user.

In this case, the error isn't very helpful (it appears the cause is Capital One is having some issues, I couldn't login online either), but that's a server error, and it'd still be nice to know that something is wrong.

egh commented 6 years ago

Thanks for the report! I figured out how to get this back from the parsed OFX file. It should now throw an exception (see https://github.com/egh/ledger-autosync/commit/7357c76a8a2f625328ab2e8f5e686d93b139dd25)