30350n / inventree_part_import

CLI to import parts from suppliers like DigiKey, LCSC, Mouser, etc. to InvenTree
MIT License
24 stars 8 forks source link

Crash when importing parts due to property validation failure #36

Closed cmidgley closed 2 months ago

cmidgley commented 2 months ago

When importing properties for parts with a unit defined and the value from the supplier API does not pass Inventree validation, the program crashes due to an invalid dereference.

To reproduce the crash, import 'USBLC6-2SC6Y' from Digikey (using the example configuration files):

inventree_part_import -o digikey USBLC6-2SC6Y

The relevant part of the stack crawl is:

  File "...\inventree_part_import\part_importer.py", line 461, in update_parameter
    return f"failed to update parameter '{parameter.name}' to '{value}' with '{msg}'"

This is because parameter does not have a 'name' property (it is an opaque object).

30350n commented 2 months ago

Thanks for catching this and reporting!

You can disable Enforce Parameter Units btw (that's what I did, so I didn't have a chance to catch this myself ^^). image

cmidgley commented 2 months ago

That's a much better solution. Merged and confirmed fixed.