Programmatically alter a field collection field item not yet saved in the database
I might try removing $library_wrapper-&gt;save(). Calling $entity_wrapper-&gt;save() within hook_node_presave() is problematic for the exact reason you're stating -- the field collection item doesn't exist yet so it doesn't have the data needed to allow it to be created/saved. Calling $entity_wrapper-&gt;save() inside of hook_node_presave() can also sometimes cause issues on its own. By setting the value but not saving it, it should act as though you entered the value in the field on the edit form and should be saved when the parent node is saved.

Alternatively, you might try hook_node_update() or hook_node_insert() instead of hook_node_presave(). These fire later in the saving process, at which point your field collection item may already exist, in which case you won't have any problem saving it