Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues after moving to new server: only hitting a certain number of items #134

Open
ctsamuraix opened this issue Jan 30, 2025 · 6 comments

Comments

@ctsamuraix
Copy link

ctsamuraix commented Jan 30, 2025

We recently moved our snipe-it server to a new server and I was able to copy everything over but when I run the script to check our jamf instance, it will query a few items then when it hits the first new one, throws the following error. Subsequent runs will successfully pass that item then do the same for the next it seems. The original server still works fine without errors. Matching config file, just adjusted the url for the new server.

Image

@ctsamuraix
Copy link
Author

Initially I had just copied the directory from the old to the new, and just in case redownloaded a fresh version to see if that made a difference, but no luck.

@ParadoxGuitarist
Copy link
Collaborator

Are you running the script from the same host?

The real issue is that there's a key that's getting injected on this line from the payload you're trying to upload:

for key in payload:

Which sounds like a config issue somewhere around line 950. I'd run this in debug and find out where that snipeit inventory script 12 is coming from.

@ctsamuraix
Copy link
Author

Looks like that field is a custom one I had pulling. I commented it out just to narrow out why that would be causing an issue, and it seems to run through more of the items in the list, but still ends up failing on other ones eventually.

@mcarras8
Copy link

mcarras8 commented Feb 5, 2025

We suddenly started receiving the same fatal error in our daily syncs, starting on 2/1.

Like @ctsamuraix's case it didn't look like the same item was erroring each time. A few times it was able to sync without issue.

Commenting out all the custom field mappings referenced in the errors seems to allow the sync to function otherwise normally for now.

We haven't made any recent changes to our setup. We are using JAMF Pro Cloud if that helps.

@ParadoxGuitarist
Copy link
Collaborator

That code block probably needs to get wrapped in a try/except to continue, but it's hard to tell without some sort of logs/output for exactly what's gonna be helpful. If either @mcarras8 or @ctsamuraix are up for providing those logs/details, (probably from --debug) it would be helpful.

@mcarras8
Copy link

mcarras8 commented Feb 6, 2025

That code block probably needs to get wrapped in a try/except to continue, but it's hard to tell without some sort of logs/output for exactly what's gonna be helpful. If either @mcarras8 or @ctsamuraix are up for providing those logs/details, (probably from --debug) it would be helpful.

Excerpt is below. Checking in Snipe-It, the update was successful.

Earlier today it errored on the custom field _snipeit_imei_21, which stores IMEI information collected from JAMF (actually it passed over this entry as no updates required). It's errored on every custom mapping intermittently.

DEBUG:root:Updating the Snipe asset because JAMF has a more recent timestamp: 2025-02-05 17:23:03 > 2025-02-02 00:00:17 or the Snipe Record is new
DEBUG:root:general is not an integer
DEBUG:root:name is not an integer
DEBUG:root:Skipping the payload, because it already exits.
DEBUG:root:hardware is not an integer
DEBUG:root:os_version is not an integer
DEBUG:root:The snipekey lookup failed, which means it's a custom field. Parsing those to see if it needs to be updated or not.
DEBUG:root:Found the field, and the value needs to be updated from 14.5.0 to 14.5
DEBUG:root:The payload for the snipe update is: {'_snipeit_mac_os_version_20': '14.5'}
DEBUG:urllib3.connectionpool:https://[our hosted snipeit instance].snipe-it.io:443 "PATCH /api/v1/hardware/1373 HTTP/1.1" 200 None
DEBUG:root:Made 10 requests to Snipe IT in 5.28851056098938 seconds, with a request being sent every 1.8908915628844258 seconds
DEBUG:root:Got back status code: 200 - Checking the payload updated properly: If you error here it's because you configure the API mapping right.
Traceback (most recent call last):
  File "C:\Scripts\Testing\SnipeIt\jamf2snipe\jamf2snipe", line 961, in <module>
    update_snipe_asset(snipe_id, updates)
  File "C:\Scripts\Testing\SnipeIt\jamf2snipe\jamf2snipe", line 621, in update_snipe_asset
    if jsonresponse['payload'][key] != payload[key]:
KeyError: '_snipeit_mac_os_version_20'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants