Fix null pointer exception when a pattern context is not found.