diff --git a/apier/v1/apier.go b/apier/v1/apier.go index 8f014db9f..ac49eff35 100644 --- a/apier/v1/apier.go +++ b/apier/v1/apier.go @@ -212,9 +212,9 @@ func (self *ApierV1) EnableDisableBalance(attr *AttrAddBalance, reply *string) e } func (self *ApierV1) ExecuteAction(attr *utils.AttrExecuteAction, reply *string) error { - tag := fmt.Sprintf("%s:%s", attr.Tenant, attr.Account) + accId := utils.AccountKey(attr.Tenant, attr.Account) at := &engine.ActionPlan{ - AccountIds: []string{tag}, + AccountIds: []string{accId}, ActionsId: attr.ActionsId, } if err := at.Execute(); err != nil { diff --git a/engine/action_plan.go b/engine/action_plan.go index c2dffa2b9..0443ebab2 100644 --- a/engine/action_plan.go +++ b/engine/action_plan.go @@ -323,6 +323,7 @@ func (at *ActionPlan) Execute() (err error) { }, 0, at.AccountIds...) if err != nil { utils.Logger.Warning(fmt.Sprintf("Error executing action plan: %v", err)) + return err } storageLogger.LogActionPlan(utils.SCHED_SOURCE, at, aac) return diff --git a/engine/actions_test.go b/engine/actions_test.go index 5a177d01c..ed52e141b 100644 --- a/engine/actions_test.go +++ b/engine/actions_test.go @@ -21,6 +21,7 @@ package engine import ( "encoding/json" "fmt" + "log" "reflect" "testing" "time" @@ -1350,6 +1351,24 @@ func TestActionTransactionBalanceType(t *testing.T) { } } +func TestActionExecuteActionNonExistingAccount(t *testing.T) { + at := &ActionPlan{ + AccountIds: []string{"cgrates.org:exe"}, + Timing: &RateInterval{}, + actions: []*Action{ + &Action{ + ActionType: TOPUP, + BalanceType: utils.MONETARY, + Balance: &Balance{Value: 1.1}, + }, + }, + } + err = at.Execute() + if err == nil { + log.Print("Fail to return error on action execute: ", err) + } +} + /**************** Benchmarks ********************************/ func BenchmarkUUID(b *testing.B) {