LCOGT/neoexchange

IndexError: string index out of range in JPL desigination fetch

Closed this issue · 2 comments

View details in Rollbar: https://rollbar.com/LCO/NEOexchange/items/214/
I was able to trigger this on demand with:

In [33]: from core.views import update_MPC_orbit

In [34]: update_MPC_orbit('62391', origin='L')
[20/Jul/2021 17:02:18] INFO More recent elements already stored for 62391
INFO:core.views:More recent elements already stored for 62391
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-34-6f6407c4e7eb> in <module>
----> 1 update_MPC_orbit('62391', origin='L')

~/git/neoexchange/neoexchange/core/views.py in update_MPC_orbit(obj_id_or_page, dbg, origin, force)
   3019     # Update Physical Parameters
   3020     if body.characterization_target() or body.source_type == 'C':
-> 3021         update_jpl_phys_params(body)
   3022         if body.source_type == 'C':
   3023             # The MPC DB doesn't return any info for comets; update the Body's

~/git/neoexchange/neoexchange/core/views.py in update_jpl_phys_params(body)
   3070     try:
   3071         store_jpl_physparams(resp['phys_par'], body)
-> 3072         store_jpl_desigs(resp['object'], body)
   3073         store_jpl_sourcetypes(resp['object']['orbit_class']['code'], resp['object'], body)
   3074     except KeyError:

~/git/neoexchange/neoexchange/astrometrics/sources_subs.py in store_jpl_desigs(obj, body)
   2718 
   2719     # parsing through JPL designations
-> 2720     des_dict_list = parse_jpl_fullname(obj)
   2721 
   2722     des_alt = obj['des_alt']

~/git/neoexchange/neoexchange/astrometrics/sources_subs.py in parse_jpl_fullname(obj)
   2780             part1, part2, part3, part4 = fullname.split(' ')
   2781             number = part1
-> 2782             if part2[0].isalpha:
   2783                 name = part2
   2784         elif space_num == 2:

IndexError: string index out of range

JPL has changed their full name designation to put two spaces instead of one between the number and the provisional designation when there is no alphanumeric name.

"fullname":"285571 (2000 PQ9)" vs "fullname":"285571 (2000 PQ9)"

This naturally cause cataclysmic failure.

We are limited in our ability to catch issues like this through testing because this represents a change in behavior on the JPL side.
Writing tests that poke the internet seem like they could be problematic.