From dfe5251f4ac97f013d02fcd64c0f02dcc3df816f Mon Sep 17 00:00:00 2001 From: Rafael Soares Date: Wed, 27 Mar 2024 18:35:23 -0300 Subject: [PATCH] if simulator max_value_length isn't configured by request get from config --- web/simulation/simulation.go | 49 ++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/web/simulation/simulation.go b/web/simulation/simulation.go index b7f8879f2..f4b3c5ba5 100644 --- a/web/simulation/simulation.go +++ b/web/simulation/simulation.go @@ -83,16 +83,15 @@ func newSimulationResponse(session flows.Session, sprint flows.Sprint) *simulati // Starts a new engine session // -// { -// "org_id": 1, -// "flows": [{ -// "uuid": uuidv4, -// "definition": {...}, -// },.. ], -// "trigger": {...}, -// "assets": {...} -// } -// +// { +// "org_id": 1, +// "flows": [{ +// "uuid": uuidv4, +// "definition": {...}, +// },.. ], +// "trigger": {...}, +// "assets": {...} +// } type startRequest struct { sessionRequest Trigger json.RawMessage `json:"trigger" validate:"required"` @@ -125,6 +124,15 @@ func handleStart(ctx context.Context, rt *runtime.Runtime, r *http.Request) (int return nil, http.StatusBadRequest, errors.Wrapf(err, "request failed validation") } + var requestTrigger map[string]interface{} + json.Unmarshal(request.Trigger, &requestTrigger) + environment, _ := requestTrigger["environment"].(map[string]interface{}) + if v := environment["max_value_length"]; v == nil { + environment["max_value_length"] = rt.Config.MaxValueLength + requestTrigger["environment"] = environment + request.Trigger, _ = json.Marshal(requestTrigger) + } + // grab our org assets oa, err := models.GetOrgAssets(ctx, rt, request.OrgID) if err != nil { @@ -164,17 +172,16 @@ func triggerFlow(ctx context.Context, rt *runtime.Runtime, oa *models.OrgAssets, // Resumes an existing engine session // -// { -// "org_id": 1, -// "flows": [{ -// "uuid": uuidv4, -// "definition": {...}, -// },.. ], -// "session": {"uuid": "468621a8-32e6-4cd2-afc1-04416f7151f0", "runs": [...], ...}, -// "resume": {...}, -// "assets": {...} -// } -// +// { +// "org_id": 1, +// "flows": [{ +// "uuid": uuidv4, +// "definition": {...}, +// },.. ], +// "session": {"uuid": "468621a8-32e6-4cd2-afc1-04416f7151f0", "runs": [...], ...}, +// "resume": {...}, +// "assets": {...} +// } type resumeRequest struct { sessionRequest