This appears closely related to
TINKERPOP-2112. I had some working code that was appending .property(T.id, str) to the results of an addE call. However, I have refactored that code so that the call to set the ID is appended to a coalesce call:
This formulation triggers the same T$2 cannot be cast to String error.