From a45c25595c6652be879fd54ec38f3fe1c0c5b77e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Mon, 19 Nov 2018 12:01:33 +0100 Subject: [PATCH] api: don't crash /api/user/{forms,drafts} when there are no formdefs (#28132) --- wcs/api.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wcs/api.py b/wcs/api.py index 7cc12f1e4..246787f1f 100644 --- a/wcs/api.py +++ b/wcs/api.py @@ -555,6 +555,9 @@ class ApiUserDirectory(Directory): return json.dumps(user_info, cls=misc.JSONEncoder) def get_user_forms(self, user): + if FormDef.count() == 0: + # early return, this avoids running a query against a missing SQL view. + return [] if get_publisher().is_using_postgresql() and not get_request().form.get('full') == 'on': from wcs import sql from qommon.storage import Equal -- 2.19.1