grokability / jamf2snipe

Import and sync assets from a JAMFPro instance to Snipe-IT asset management.
MIT License
113 stars 55 forks source link

Script crashes on missing asset tag #91

Closed bondurantdt closed 2 years ago

bondurantdt commented 2 years ago

Hello, I am using the devel branch of the script and currently when running ./jamf2snipe -v --do_not_update_jamf -m the script crashes part way through when it tries to deal with a new asset for Snipe-IT and the JAMF asset does not have a value present for Asset Tag. Thanks for the help!

INFO:root:Creating a new asset in snipe for JAMF ID 25 - ios Traceback (most recent call last): File "/Users/davidbondurant/GitHub/jamf2snipe/./jamf2snipe", line 791, in jamf_asset_tag = jamf['{}'.format(tag_split[0])]['{}'.format(tag_split[1])] KeyError: 'assetTag'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/davidbondurant/GitHub/jamf2snipe/./jamf2snipe", line 793, in raise SystemError('No such attribute {} in the jamf payload. Please check your settings.conf file'.format(tag_split)) SystemError: No such attribute ['general', 'assetTag', '#', 'If', 'not', 'specified,', 'defaults', 'to', 'jamf-{id}', 'or', 'jamf-m-{id}'] in the jamf payload. Please check your settings.conf file

ParadoxGuitarist commented 2 years ago

I know we fixed something similar to this recently. Can you test the devel branch? ./jamf2snipe --version should give you a number. It might still be broken, but that will give us an updated line number since this might be older.

ParadoxGuitarist commented 2 years ago

Whomp, I missed the part where you already mentioned the devel branch. :) My bad.

bondurantdt commented 2 years ago

So while my PR solved this for my environ, I could see some other, potentially better, ways to handle this.

Hard crashing/exiting the script seems like always unwanted behavior to me since in my mind this script is meant to be an unattended/cron script. Ensuring logic will log an error and move on feels like the right approach.

At this point I would consider this issue resolved, and these things are more of an enhancement request. Maybe if I get some time... 😆