Prevent NoSuchElementException in Extract trait.

Fixes #1001967