Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix simulator max value length #101

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 28 additions & 21 deletions web/simulation/simulation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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

Expand Down
Loading