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({