Skip to content

Commit ddb6008

Browse files
committed
Require user and package fields in create application API
Check for mandatory user and package fields in create application API. Return helpful errors if they are missing. PNDA-4405
1 parent 4670089 commit ddb6008

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

api/src/main/resources/app.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,13 +256,20 @@ class ApplicationHandler(BaseHandler):
256256
def put(self, aname):
257257
try:
258258
request_body = json.loads(self.request.body)
259-
pname = request_body['package']
260-
except:
259+
except ValueError:
261260
self.send_client_error("Invalid request body")
262261
return
263262

263+
if 'package' not in request_body:
264+
self.send_client_error("Invalid request body. Missing field 'package'")
265+
return
266+
267+
if 'user' not in request_body:
268+
self.send_client_error("Invalid request body. Missing field 'user'")
269+
return
270+
264271
def do_call():
265-
dm.create_application(pname, aname, request_body)
272+
dm.create_application(request_body['package'], aname, request_body)
266273
self.send_accepted()
267274

268275
DISPATCHER.run_as_asynch(task=do_call, on_error=self.handle_error)

0 commit comments

Comments
 (0)