Commit bc77409d authored by zaake's avatar zaake
Browse files

Don't fail on LiquidRenderError for register and check.

parent eddeeed2
Pipeline #186955 passed with stages
in 1 minute and 22 seconds
......@@ -9,6 +9,7 @@ from typing import Any, Dict, Optional, Union
import fastapi
import fastapi.responses
from fastapi import BackgroundTasks, FastAPI, Request
from liquid import LiquidRenderError
from annotator import access_log, error_log
from annotator import config
......@@ -48,19 +49,25 @@ def aw_endpoint(payload: awmodels.RequestCommon, background_tasks: BackgroundTas
credentials=payload.params.credentials,
)
if payload.method is not None and payload.method == "register":
return register(payload=awmodels.RequestRegister.parse_obj(payload.dict()))
elif payload.method is not None and payload.method == "receive":
return receive(
payload=awmodels.RequestReceive.parse_obj(payload.dict()),
background_tasks=background_tasks,
)
elif payload.method is not None and payload.method == "check":
return check(
payload=awmodels.RequestCheck.parse_obj(payload.dict()),
)
# Only receive will get a message to be parsed. So only receive's RendererError is raised to AW in readable form.
if payload.method == "receive":
try:
return receive(
payload=awmodels.RequestReceive.parse_obj(payload.dict()),
background_tasks=background_tasks)
except LiquidRenderError as e:
raise errors.ActiveWorkflowError(
name="Liquid Templating Error",
message="There might be a syntax problem with liquid templating:\n" + e)
else:
try:
if payload.method == "register":
return register(payload=awmodels.RequestRegister.parse_obj(payload.dict()))
elif payload.method == "check":
return check(payload=awmodels.RequestCheck.parse_obj(payload.dict()))
except LiquidRenderError as e:
# We don't expect a message to be passed, so an RendererError will occur. That's OK.
return
raise errors.ActiveWorkflowError(
name="Method Error",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment