thedatahub / Datahub-Factory

Datahub::Factory - Transport metadata between Collection Management Systems and the Datahub
Other
2 stars 4 forks source link

Transport command throws use of uninitialized value $item_id error #45

Closed netsensei closed 7 years ago

netsensei commented 7 years ago

Problem

The transport command will throw an error while processing a record if it can't retrieve the object identifier from the record as identified via the id_path property in the pipeline configuration.

Use of uninitialized value $item_id in sprintf at /Users/matthiasvandermaesen/.plenv/versions/5.22.0/lib/perl5/site_perl/5.22.0/Datahub/Factory/Command/transport.pm line 93.

Cause

The identifier is retrieved independently from the module pipeline by the transport command via a hard-coded data_at function call. This call is made right after the item is fixed and exported.

At this point, it's unsure whether or not the fix removed the identifier (which is a valid use case) from the record.

Moreover, theid_path property is part of the fixer config block which can structurally differ per use case if fix conditions were used or not. In the former case, the id_path is part of the defined fixer, in the latter case it's part of the generic 'fix' block.

Solution

Move the fetching of the id_path to the importer instead of the fixer or exporter as this guarantees that we can retrieve the id in an unambiguous fashion.

If the ID couldn't be fetched, the processing message should fall back to a graceful alternative instead of throwing an error.