mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Fix exception in webhook validation
This commit is contained in:
parent
5c9b59f9e8
commit
279ad61a1b
@ -99,13 +99,21 @@ class ApiServersServerWebhooksIndexHandler(BaseApiHandler):
|
||||
|
||||
try:
|
||||
validate(data, new_webhook_schema)
|
||||
except ValidationError as e:
|
||||
except ValidationError as why:
|
||||
offending_key = None
|
||||
if why.get("fill", None):
|
||||
offending_key = why.path[0] if why.path else None
|
||||
err = f"""{self.translator.translate(
|
||||
"validators",
|
||||
why.schema.get("error"),
|
||||
self.controller.users.get_user_lang_by_id(auth_data[4]["user_id"]),
|
||||
)} {offending_key}"""
|
||||
return self.finish_json(
|
||||
400,
|
||||
{
|
||||
"status": "error",
|
||||
"error": "INVALID_JSON_SCHEMA",
|
||||
"error_data": str(e),
|
||||
"error_data": f"{str(err)}",
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -137,13 +137,21 @@ class ApiServersServerWebhooksManagementIndexHandler(BaseApiHandler):
|
||||
|
||||
try:
|
||||
validate(data, webhook_patch_schema)
|
||||
except ValidationError as e:
|
||||
except ValidationError as why:
|
||||
offending_key = None
|
||||
if why.get("fill", None):
|
||||
offending_key = why.path[0] if why.path else None
|
||||
err = f"""{self.translator.translate(
|
||||
"validators",
|
||||
why.schema.get("error"),
|
||||
self.controller.users.get_user_lang_by_id(auth_data[4]["user_id"]),
|
||||
)} {offending_key}"""
|
||||
return self.finish_json(
|
||||
400,
|
||||
{
|
||||
"status": "error",
|
||||
"error": "INVALID_JSON_SCHEMA",
|
||||
"error_data": str(e),
|
||||
"error_data": f"{str(err)}",
|
||||
},
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user