Check for missing application

This is a "duh" bug. The code was blindly assuming that a database
record was found in all cases.

Bug: 58046
Change-Id: I7c8d1d39cddc3a4b6b5c6e7a10fb7482216c2344