Island: Catch ValueError and TypeError instead of InvalidConfigurationError in resource AgentConfiguration's PUT

This commit is contained in:
Shreya Malviya 2022-08-29 19:45:35 +05:30
parent 433e154cd1
commit fe792ffc6f
1 changed files with 1 additions and 2 deletions

View File

@ -5,7 +5,6 @@ from flask import make_response, request
from common.agent_configuration.agent_configuration import ( from common.agent_configuration.agent_configuration import (
AgentConfiguration as AgentConfigurationObject, AgentConfiguration as AgentConfigurationObject,
) )
from common.agent_configuration.agent_configuration import InvalidConfigurationError
from monkey_island.cc.repository import IAgentConfigurationRepository from monkey_island.cc.repository import IAgentConfigurationRepository
from monkey_island.cc.resources.AbstractResource import AbstractResource from monkey_island.cc.resources.AbstractResource import AbstractResource
from monkey_island.cc.resources.request_authentication import jwt_required from monkey_island.cc.resources.request_authentication import jwt_required
@ -30,7 +29,7 @@ class AgentConfiguration(AbstractResource):
self._agent_configuration_repository.store_configuration(configuration_object) self._agent_configuration_repository.store_configuration(configuration_object)
# API Spec: Should return 204 (NO CONTENT) # API Spec: Should return 204 (NO CONTENT)
return make_response({}, 200) return make_response({}, 200)
except (InvalidConfigurationError, json.JSONDecodeError) as err: except (ValueError, TypeError, json.JSONDecodeError) as err:
return make_response( return make_response(
{"error": f"Invalid configuration supplied: {err}"}, {"error": f"Invalid configuration supplied: {err}"},
400, 400,