From 92c0b5ac3ebf154207ac810a77f00aaccc5e504b Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Thu, 16 Feb 2017 15:26:45 -0500 Subject: [PATCH] Fix handling of None queries --- endpoints/v1/index.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/endpoints/v1/index.py b/endpoints/v1/index.py index b15af1b84..c9a4c72dd 100644 --- a/endpoints/v1/index.py +++ b/endpoints/v1/index.py @@ -287,7 +287,7 @@ def put_repository_auth(namespace_name, repo_name): @process_auth @anon_protect def get_search(): - query = request.args.get('q') + query = request.args.get('q') or '' try: limit = min(100, max(1, int(request.args.get('n', 25)))) @@ -327,8 +327,13 @@ def _conduct_repo_search(username, query, limit=25, page=1): page = min(page, _MAX_PAGE_COUNT) only_public = username is None - matching_repos = model.get_sorted_matching_repositories(query, only_public, can_read, - limit=limit*_MAX_PAGE_COUNT) + + if query: + matching_repos = model.get_sorted_matching_repositories(query, only_public, can_read, + limit=limit*_MAX_PAGE_COUNT) + else: + matching_repos = [] + results = [] for repo in matching_repos[(page - 1) * _MAX_PAGE_COUNT:limit]: results.append({