Test if we have a valid path before using it.

Ticket: #6843