diff --git a/engine/libfilters.go b/engine/libfilters.go index 675f46fa4..ed851ccb1 100644 --- a/engine/libfilters.go +++ b/engine/libfilters.go @@ -262,7 +262,7 @@ func GetIntPointerOpts(ctx *context.Context, tnt string, ev *utils.CGREvent, fS return opt.Value, nil } } - return nil, utils.ErrNotFound // return NOT_FOUND if there are no options and none of the filters pass + return nil, nil } // GetDurationPointerOptsFromMultipleMaps checks the specified option names in order among the keys in APIOpts, then in startOpts, returning the first value it finds as *time.Duration, @@ -295,7 +295,7 @@ func GetDurationPointerOptsFromMultipleMaps(ctx *context.Context, tnt string, ev return opt.Value, nil } } - return nil, utils.ErrNotFound // return NOT_FOUND if there are no options and none of the filters pass + return nil, nil } // GetDurationOptsFromMultipleMaps checks the specified option names in order among the keys in APIOpts, then in startOpts, returning the first value it finds as time.Duration, diff --git a/engine/libfilters_test.go b/engine/libfilters_test.go index 722be6f6d..445721a5e 100644 --- a/engine/libfilters_test.go +++ b/engine/libfilters_test.go @@ -1367,7 +1367,7 @@ func TestLibFiltersGetIntPointerOptsFilterCheckErr(t *testing.T) { } } -func TestLibFiltersGetIntPointerOptsErrNotFound(t *testing.T) { +func TestLibFiltersGetIntPointerOptsReturnDft(t *testing.T) { cfg := config.NewDefaultCGRConfig() dataDB := NewInternalDB(nil, nil, nil) dm := NewDataManager(dataDB, cfg.CacheCfg(), nil) @@ -1390,8 +1390,8 @@ func TestLibFiltersGetIntPointerOptsErrNotFound(t *testing.T) { } if _, err := GetIntPointerOpts(context.Background(), "cgrates.org", ev, fS, dynOpts, - utils.OptsRoutesProfilesCount); err == nil || err.Error() != utils.ErrNotFound.Error() { - t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.ErrNotFound, err) + utils.OptsRoutesProfilesCount); err != nil { + t.Error(err) } } @@ -1740,7 +1740,7 @@ func TestLibFiltersGetDurationPointerOptsFromMultipleMapsFilterCheckErr(t *testi } } -func TestLibFiltersGetDurationPointerOptsFromMultipleMapsErrNotFound(t *testing.T) { +func TestLibFiltersGetDurationPointerOptsFromMultipleMapsReturnDft(t *testing.T) { cfg := config.NewDefaultCGRConfig() dataDB := NewInternalDB(nil, nil, nil) dm := NewDataManager(dataDB, cfg.CacheCfg(), nil) @@ -1760,8 +1760,8 @@ func TestLibFiltersGetDurationPointerOptsFromMultipleMapsErrNotFound(t *testing. } if _, err := GetDurationPointerOptsFromMultipleMaps(context.Background(), "cgrates.org", eventStart, apiOpts, startOpts, fS, dynOpts, - utils.OptsSesTTLUsage); err == nil || err.Error() != utils.ErrNotFound.Error() { - t.Errorf("expected: <%+v>, \nreceived: <%+v>", utils.ErrNotFound, err) + utils.OptsSesTTLUsage); err != nil { + t.Error(err) } } diff --git a/sessions/sessions.go b/sessions/sessions.go index a658e588f..f40daf6de 100644 --- a/sessions/sessions.go +++ b/sessions/sessions.go @@ -243,34 +243,28 @@ func (sS *SessionS) setSTerminator(ctx *context.Context, s *Session, opts engine var ttlLastUsed *time.Duration if ttlLastUsed, err = engine.GetDurationPointerOptsFromMultipleMaps(ctx, s.Tenant, s.EventStart, opts, s.OptsStart, sS.fltrS, sS.cfg.SessionSCfg().Opts.TTLLastUsed, utils.OptsSesTTLLastUsed); err != nil { - if err != utils.ErrNotFound { - utils.Logger.Warning( - fmt.Sprintf("<%s>, cannot extract <%s> for session:<%s>, from its options: <%s>, err: <%s>", - utils.SessionS, utils.OptsSesTTLLastUsed, s.OptsStart[utils.MetaOriginID], opts.String(), err.Error())) - return - } + utils.Logger.Warning( + fmt.Sprintf("<%s>, cannot extract <%s> for session:<%s>, from its options: <%s>, err: <%s>", + utils.SessionS, utils.OptsSesTTLLastUsed, s.OptsStart[utils.MetaOriginID], opts.String(), err.Error())) + return } // LastUsage var ttlLastUsage *time.Duration if ttlLastUsage, err = engine.GetDurationPointerOptsFromMultipleMaps(ctx, s.Tenant, s.EventStart, opts, s.OptsStart, sS.fltrS, sS.cfg.SessionSCfg().Opts.TTLLastUsage, utils.OptsSesTTLLastUsage); err != nil { - if err != utils.ErrNotFound { - utils.Logger.Warning( - fmt.Sprintf("<%s>, cannot extract <%s> for session:<%s>, from its options: <%s>, err: <%s>", - utils.SessionS, utils.OptsSesTTLLastUsage, s.OptsStart[utils.MetaOriginID], opts.String(), err.Error())) - return - } + utils.Logger.Warning( + fmt.Sprintf("<%s>, cannot extract <%s> for session:<%s>, from its options: <%s>, err: <%s>", + utils.SessionS, utils.OptsSesTTLLastUsage, s.OptsStart[utils.MetaOriginID], opts.String(), err.Error())) + return } // TTLUsage var ttlUsage *time.Duration if ttlUsage, err = engine.GetDurationPointerOptsFromMultipleMaps(ctx, s.Tenant, s.EventStart, opts, s.OptsStart, sS.fltrS, sS.cfg.SessionSCfg().Opts.TTLUsage, utils.OptsSesTTLUsage); err != nil { - if err != utils.ErrNotFound { - utils.Logger.Warning( - fmt.Sprintf("<%s>, cannot extract <%s> for session:<%s>, from its options: <%s>, err: <%s>", - utils.SessionS, utils.OptsSesTTLUsage, s.OptsStart[utils.MetaOriginID], opts.String(), err.Error())) - return - } + utils.Logger.Warning( + fmt.Sprintf("<%s>, cannot extract <%s> for session:<%s>, from its options: <%s>, err: <%s>", + utils.SessionS, utils.OptsSesTTLUsage, s.OptsStart[utils.MetaOriginID], opts.String(), err.Error())) + return } // previously defined, reset if s.sTerminator != nil {