diff --git a/flows/actions/call_classifier.go b/flows/actions/call_classifier.go index 640a3ec2a..ff1f76c5f 100644 --- a/flows/actions/call_classifier.go +++ b/flows/actions/call_classifier.go @@ -38,7 +38,7 @@ type CallClassifierAction struct { Classifier *assets.ClassifierReference `json:"classifier" validate:"required"` Input string `json:"input" validate:"required" engine:"evaluated"` - ResultName string `json:"result_name" validate:"required"` + ResultName string `json:"result_name" validate:"required,max=128"` } // NewCallClassifier creates a new call classifier action diff --git a/flows/actions/call_resthook.go b/flows/actions/call_resthook.go index c1f59c67c..4d54d4cd5 100644 --- a/flows/actions/call_resthook.go +++ b/flows/actions/call_resthook.go @@ -66,8 +66,8 @@ type CallResthookAction struct { baseAction onlineAction - Resthook string `json:"resthook" validate:"required"` - ResultName string `json:"result_name,omitempty"` + Resthook string `json:"resthook" validate:"required"` + ResultName string `json:"result_name,omitempty" validate:"max=128"` } // NewCallResthook creates a new call resthook action diff --git a/flows/actions/call_webhook.go b/flows/actions/call_webhook.go index ca35d9294..650b858e4 100644 --- a/flows/actions/call_webhook.go +++ b/flows/actions/call_webhook.go @@ -52,11 +52,11 @@ type CallWebhookAction struct { baseAction onlineAction - Method string `json:"method" validate:"required,http_method"` - URL string `json:"url" validate:"required" engine:"evaluated"` - Headers map[string]string `json:"headers,omitempty" engine:"evaluated"` - Body string `json:"body,omitempty" engine:"evaluated"` - ResultName string `json:"result_name,omitempty"` + Method string `json:"method" validate:"required,http_method"` + URL string `json:"url" engine:"evaluated" validate:"required"` + Headers map[string]string `json:"headers,omitempty" engine:"evaluated"` + Body string `json:"body,omitempty" engine:"evaluated"` + ResultName string `json:"result_name,omitempty" validate:"max=128"` } // NewCallWebhook creates a new call webhook action diff --git a/flows/actions/open_ticket.go b/flows/actions/open_ticket.go index ecba7289d..bb709e0a6 100644 --- a/flows/actions/open_ticket.go +++ b/flows/actions/open_ticket.go @@ -35,10 +35,10 @@ type OpenTicketAction struct { baseAction onlineAction - Topic *assets.TopicReference `json:"topic" validate:"omitempty"` + Topic *assets.TopicReference `json:"topic" validate:"omitempty"` Body string `json:"body" engine:"evaluated"` // TODO will become "note" in future migration - Assignee *assets.UserReference `json:"assignee" validate:"omitempty"` - ResultName string `json:"result_name" validate:"required"` + Assignee *assets.UserReference `json:"assignee" validate:"omitempty"` + ResultName string `json:"result_name" validate:"required,max=128"` } // NewOpenTicket creates a new open ticket action diff --git a/flows/actions/set_run_result.go b/flows/actions/set_run_result.go index f1c2ae055..4b16c4bcb 100644 --- a/flows/actions/set_run_result.go +++ b/flows/actions/set_run_result.go @@ -32,9 +32,9 @@ type SetRunResultAction struct { baseAction universalAction - Name string `json:"name" validate:"required"` - Value string `json:"value" engine:"evaluated"` - Category string `json:"category,omitempty" engine:"localized"` + Name string `json:"name" validate:"required,max=128"` + Value string `json:"value" engine:"evaluated"` + Category string `json:"category,omitempty" engine:"localized" validate:"max=128"` } // NewSetRunResult creates a new set run result action diff --git a/flows/actions/testdata/call_resthook.json b/flows/actions/testdata/call_resthook.json index 432a4ebdb..34624223e 100644 --- a/flows/actions/testdata/call_resthook.json +++ b/flows/actions/testdata/call_resthook.json @@ -1,4 +1,14 @@ [ + { + "description": "Read fails when result name is too long", + "action": { + "type": "call_resthook", + "uuid": "ad154980-7bf7-4ab8-8728-545fd6378912", + "resthook": "doesnt-exist", + "result_name": "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" + }, + "read_error": "field 'result_name' must be less than or equal to 128" + }, { "description": "NOOP if resthook doesn't exist", "action": { diff --git a/flows/actions/testdata/call_webhook.json b/flows/actions/testdata/call_webhook.json index 0538f20fa..78d9910e5 100644 --- a/flows/actions/testdata/call_webhook.json +++ b/flows/actions/testdata/call_webhook.json @@ -23,6 +23,21 @@ }, "read_error": "header 'Accept:' is not a valid HTTP header" }, + { + "description": "Read fails when result name is too long", + "action": { + "type": "call_webhook", + "uuid": "ad154980-7bf7-4ab8-8728-545fd6378912", + "method": "POST", + "url": "http://temba.io/", + "body": "Hi there!", + "headers": { + "Accept:": "something" + }, + "result_name": "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" + }, + "read_error": "field 'result_name' must be less than or equal to 128" + }, { "description": "Error events created if URL, header or body contain expression errors", "http_mocks": { diff --git a/flows/actions/testdata/open_ticket.json b/flows/actions/testdata/open_ticket.json index 6e525e4dd..801e1e9a4 100644 --- a/flows/actions/testdata/open_ticket.json +++ b/flows/actions/testdata/open_ticket.json @@ -1,4 +1,19 @@ [ + { + "description": "Read fails when result name is too long", + "action": { + "type": "open_ticket", + "uuid": "ad154980-7bf7-4ab8-8728-545fd6378912", + "topic": { + "uuid": "dc61e948-26a1-407e-9739-b73b46400b51", + "name": "Deleted" + }, + "body": "Where are my cookies?", + "assignee": null, + "result_name": "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" + }, + "read_error": "field 'result_name' must be less than or equal to 128" + }, { "description": "Error event for invalid topic reference", "action": { diff --git a/flows/actions/testdata/set_run_result.json b/flows/actions/testdata/set_run_result.json index 84ca2a6ea..1d2e311a0 100644 --- a/flows/actions/testdata/set_run_result.json +++ b/flows/actions/testdata/set_run_result.json @@ -1,4 +1,26 @@ [ + { + "description": "Read fails when name is empty", + "action": { + "uuid": "ad154980-7bf7-4ab8-8728-545fd6378912", + "type": "set_run_result", + "name": "", + "value": "bar", + "category": "" + }, + "read_error": "field 'name' is required" + }, + { + "description": "Read fails when category is too long", + "action": { + "uuid": "ad154980-7bf7-4ab8-8728-545fd6378912", + "type": "set_run_result", + "name": "Foo", + "value": "bar", + "category": "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" + }, + "read_error": "field 'category' must be less than or equal to 128" + }, { "description": "Error event and action skipped if value contains expression error", "action": { diff --git a/flows/actions/transfer_airtime.go b/flows/actions/transfer_airtime.go index ffbb2796a..df79796b4 100644 --- a/flows/actions/transfer_airtime.go +++ b/flows/actions/transfer_airtime.go @@ -34,8 +34,8 @@ type TransferAirtimeAction struct { baseAction onlineAction - Amounts map[string]decimal.Decimal `json:"amounts" validate:"required"` - ResultName string `json:"result_name" validate:"required"` + Amounts map[string]decimal.Decimal `json:"amounts" validate:"required"` + ResultName string `json:"result_name" validate:"required,max=128"` } // NewTransferAirtime creates a new airtime transfer action