fix: panic when executing action with no arguments

This commit is contained in:
jamesread 2025-10-30 13:04:12 +00:00
parent a8f5e25454
commit a4e50bfb54
2 changed files with 17 additions and 24 deletions

View File

@ -88,24 +88,16 @@ func LoadUserSessions(cfg *config.Config) {
data, err := os.ReadFile(cfg.GetDir() + "/sessions.yaml")
if err != nil {
logrus.WithError(err).Warn("Failed to read sessions.yaml file")
// Initialize empty session storage if file doesn't exist
if sessionStorage == nil {
sessionStorage = &SessionStorage{
Providers: make(map[string]*SessionProvider),
}
}
// Always reset in-memory sessions on load error
sessionStorage = &SessionStorage{Providers: make(map[string]*SessionProvider)}
return
}
err = yaml.Unmarshal(data, &sessionStorage)
if err != nil {
logrus.WithError(err).Error("Failed to unmarshal sessions.yaml")
// Initialize empty session storage if unmarshal fails
if sessionStorage == nil {
sessionStorage = &SessionStorage{
Providers: make(map[string]*SessionProvider),
}
}
// Always reset in-memory sessions on parse error
sessionStorage = &SessionStorage{Providers: make(map[string]*SessionProvider)}
return
}

View File

@ -436,8 +436,6 @@ func stepParseArgs(req *ExecutionRequest) bool {
req.Arguments["ot_executionTrackingId"] = req.TrackingID
req.Arguments["ot_username"] = req.AuthenticatedUser.Username
mangleInvalidArgumentValues(req)
if req.Binding == nil || req.Binding.Action == nil {
err = fmt.Errorf("cannot parse arguments: Binding or Action is nil")
req.logEntry.Output = err.Error()
@ -445,6 +443,9 @@ func stepParseArgs(req *ExecutionRequest) bool {
return false
}
// Only mangle arguments when we have a valid binding/action
mangleInvalidArgumentValues(req)
if len(req.Binding.Action.Exec) > 0 {
req.useDirectExec = true
req.execArgs, err = parseActionExec(req.Arguments, req.Binding.Action, req.Binding.Entity)