[discover] Cannot read property 'query' of undefined

While adding a filter discover tries to find an existing filter that matches. That code was trying to read a property on an object that is wasn't checking exists first.

Fixes #2022