pulibrary / pdc-osti

2 stars 0 forks source link

Bug: Script fails for records without ARKs #65

Closed astrochun closed 7 months ago

astrochun commented 8 months ago

Now that we have a mix of records with and without ARKs, it's now breaks in cases where one does not exist (new records):

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.11.7/x64/bin/scraper", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/runner/work/pdc-osti/pdc-osti/src/pdc_osti/scraper.py", line 421, in main
    s.run_pipeline()
  File "/home/runner/work/pdc-osti/pdc-osti/src/pdc_osti/scraper.py", line 361, in run_pipeline
    self.get_unposted_metadata()
  File "/home/runner/work/pdc-osti/pdc-osti/src/pdc_osti/scraper.py", line 2[28](https://github.com/pulibrary/pdc-osti/actions/runs/7376863887/job/20070155428#step:6:29), in get_unposted_metadata
    princeton_handles = [get_ark(record) for record in princeton_j]
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/pdc-osti/pdc-osti/src/pdc_osti/scraper.py", line 228, in <listcomp>
    princeton_handles = [get_ark(record) for record in princeton_j]
                         ^^^^^^^^^^^^^^^
  File "/home/runner/work/pdc-osti/pdc-osti/src/pdc_osti/commons.py", line 4, in get_ark
    return record["resource"]["ark"].replace("ark:/", "")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'replace'
Error: Process completed with exit code 1.

A try and exception should be pursued.