Commit 5da4632a authored by zaake's avatar zaake
Browse files

Merge branch 'zaake-fix-aw_endpoint' into 'master'

Zaake fix aw endpoint

See merge request !10
parents eddeeed2 2aa27234
Pipeline #187537 passed with stages
in 1 minute and 56 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
......@@ -42,11 +43,25 @@ def aw_endpoint(payload: awmodels.RequestCommon, background_tasks: BackgroundTas
# Replace Liquid Templating markup in provided options. Values from message and credentials may be
# referenced in Liquid statements.
payload.params.options = utils.render_liquid(
options=payload.params.options,
message=payload.params.message,
credentials=payload.params.credentials,
)
try:
payload.params.options = utils.render_liquid(
options=payload.params.options,
message=payload.params.message,
credentials=payload.params.credentials,
)
except LiquidRenderError as e:
# Only receive will get a message to be parsed. So only receive's RendererError shall be relayed
# to ActiveWorkflow in readable form.
# Error might be caused by a missing message that is referred to in an options parameter which
# is not required for check or register methods
if payload.method == "receive":
raise errors.ActiveWorkflowError(
name="Liquid Templating Error",
message=str(e))
else:
# Continue with normal operations. If missing Liquid replacement has consequences,
# further processing will raise according exceptions
pass
if payload.method is not None and payload.method == "register":
return register(payload=awmodels.RequestRegister.parse_obj(payload.dict()))
......
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