Ensure we have a list of valid ids before trying to retrieve them from the database.