From 2863c58264e13bfa44acda898a46ca2aaed11e5b Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 8 May 2014 14:39:44 -0400 Subject: [PATCH] Fix core to return invalidargument exception on bad input data --- TODO | 1 + confluent_server/confluent/core.py | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/TODO b/TODO index 3af93b9a..5fd9c0cf 100644 --- a/TODO +++ b/TODO @@ -31,3 +31,4 @@ KeyError: '' a titlebar -audit log did not show confetty activity for starting console -read exclusive and full exclusive console access modes +-invalid attributes at create time come out as 500 \ No newline at end of file diff --git a/confluent_server/confluent/core.py b/confluent_server/confluent/core.py index 8a057912..da12f4ed 100644 --- a/confluent_server/confluent/core.py +++ b/confluent_server/confluent/core.py @@ -233,7 +233,10 @@ def create_group(inputdata, configmanager): attribmap = {groupname: inputdata} except KeyError: raise exc.InvalidArgumentException() - configmanager.add_group_attributes(attribmap) + try: + configmanager.add_group_attributes(attribmap) + except ValueError as e: + raise exc.InvalidArgumentException(str(e)) def create_node(inputdata, configmanager): @@ -242,8 +245,11 @@ def create_node(inputdata, configmanager): del inputdata['name'] attribmap = {nodename: inputdata} except KeyError: - raise exc.InvalidArgumentException() - configmanager.add_node_attributes(attribmap) + raise exc.InvalidArgumentException('name not specified') + try: + configmanager.add_node_attributes(attribmap) + except ValueError as e: + raise exc.InvalidArgumentException(str(e)) def enumerate_collections(collections):