NYPL-Simplified / circulation

Circulation manager for Library Simplified
Other
19 stars 19 forks source link

Overdrive representation edge cases crash scripts #350

Closed leonardr closed 8 years ago

leonardr commented 8 years ago

I see a couple cases where an unexpected bit of missing data or weird representation causes an Overdrive script to crash. We should be able to handle these representations assuming they're not totally broken. And if there's one representation we can't handle it shouldn't crash the whole script, we should just move on to the next representation.

leonardr commented 8 years ago

Traceback (most recent call last):
  File "/var/lib/app/circulation/core/scripts.py", line 111, in run
    self.do_run()
  File "/var/lib/app/circulation/core/scripts.py", line 132, in do_run
    self.monitor.run()
  File "/var/lib/app/circulation/api/overdrive.py", line 810, in run
    super(OverdriveCirculationMonitor, self).run()
  File "/var/lib/app/circulation/core/monitor.py", line 74, in run
    new_timestamp = self.run_once(start, cutoff) or cutoff
  File "/var/lib/app/circulation/api/overdrive.py", line 820, in run_once
    for i, book in enumerate(self.recently_changed_ids(start, cutoff)):
  File "/var/lib/app/circulation/core/overdrive.py", line 236, in all_ids
    next_link, 'next'
  File "/var/lib/app/circulation/core/overdrive.py", line 258, in _get_book_list_page
    OverdriveRepresentationExtractor.availability_link_list(data))
  File "/var/lib/app/circulation/core/overdrive.py", line 405, in availability_link_list
    title=product['title'],
KeyError: 'title'
leonardr commented 8 years ago

This crashed the Overdrive Collection Reaper:

Traceback (most recent call last):
  File "/var/lib/app/circulation/core/monitor.py", line 231, in run
    new_offset = self.run_once(offset)
  File "/var/lib/app/circulation/core/monitor.py", line 260, in run_once
    self.process_batch(identifiers)
  File "/var/lib/app/circulation/api/overdrive.py", line 888, in process_batch
    self.api.update_licensepool(i.identifier)
  File "/var/lib/app/circulation/api/overdrive.py", line 637, in update_licensepool
    book['id'], status_code
TypeError: string indices must be integers