diff --git a/services/inventory/http_routes.go b/services/inventory/http_routes.go index 806ad2525..77fae7335 100644 --- a/services/inventory/http_routes.go +++ b/services/inventory/http_routes.go @@ -1113,9 +1113,12 @@ func (h *HttpHandler) RunQueryByID(ctx echo.Context) error { if err := bindValidate(ctx, &req); err != nil { return echo.NewHTTPError(http.StatusBadRequest, err.Error()) } - if req.ID == "" || req.Type == "" { + if req.ID == "" { return echo.NewHTTPError(http.StatusBadRequest, "Runnable Type and ID should be provided") } + if req.Type == "" { + req.Type = "namedquery" + } newCtx, cancel := context.WithTimeout(ctx.Request().Context(), 30*time.Second) defer cancel() diff --git a/services/tasks/scheduler/publisher.go b/services/tasks/scheduler/publisher.go index 27ae10134..c4973c994 100644 --- a/services/tasks/scheduler/publisher.go +++ b/services/tasks/scheduler/publisher.go @@ -35,7 +35,7 @@ func (s *TaskScheduler) runPublisher(ctx context.Context) error { params, err := JSONBToMap(run.Params) if err != nil { result := pgtype.JSONB{} - _ = result.Set([]byte("")) + _ = result.Set([]byte("{}")) _ = s.db.UpdateTaskRun(run.ID, models.TaskRunStatusFailed, result, "failed to get params") s.logger.Error("failed to get params", zap.Error(err), zap.Uint("runId", run.ID)) return err @@ -55,7 +55,7 @@ func (s *TaskScheduler) runPublisher(ctx context.Context) error { reqJson, err := json.Marshal(req) if err != nil { result := pgtype.JSONB{} - _ = result.Set([]byte("")) + _ = result.Set([]byte("{}")) _ = s.db.UpdateTaskRun(run.ID, models.TaskRunStatusFailed, result, "failed to marshal run") s.logger.Error("failed to marshal Task Run", zap.Error(err), zap.Uint("runId", run.ID)) return err @@ -73,21 +73,21 @@ func (s *TaskScheduler) runPublisher(ctx context.Context) error { _, err = s.jq.Produce(ctx, s.NatsConfig.Topic, reqJson, fmt.Sprintf("run-%d", run.ID)) if err != nil { result := pgtype.JSONB{} - _ = result.Set([]byte("")) + _ = result.Set([]byte("{}")) _ = s.db.UpdateTaskRun(run.ID, models.TaskRunStatusFailed, result, err.Error()) s.logger.Error("failed to send run", zap.Error(err), zap.Uint("runId", run.ID)) continue } } else { result := pgtype.JSONB{} - _ = result.Set([]byte("")) + _ = result.Set([]byte("{}")) _ = s.db.UpdateTaskRun(run.ID, models.TaskRunStatusFailed, result, err.Error()) s.logger.Error("failed to send run", zap.Error(err), zap.Uint("runId", run.ID), zap.String("error message", err.Error())) continue } } else { result := pgtype.JSONB{} - _ = result.Set([]byte("")) + _ = result.Set([]byte("{}")) _ = s.db.UpdateTaskRun(run.ID, models.TaskRunStatusQueued, result, "") } }