Script crashes on missing asset tag
bondurantdt opened this issue · 3 comments
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
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.
Whomp, I missed the part where you already mentioned the devel branch. :) My bad.
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.
- Create a user flag that allows for the behavior of a missing asset tag in JAMF. Default behavior will be if asset tag is missing in JAMF behave the newly updated way of, log an error, skip creating the asset and move on. Flag on behavior will be the behavior in my PR.
- Adding code to support emailing an admin an asset exception CSV so they can quickly identify and fix their JAMF data would be another handy little feature.
At this point I would consider this issue resolved, and these things are more of an enhancement request. Maybe if I get some time... 😆