From 41215bdc0a9c81aa5250ef36a2f60a48f871e71b Mon Sep 17 00:00:00 2001 From: Silvan Date: Fri, 5 Jan 2024 07:29:57 +0100 Subject: [PATCH] fix(setup): unmarshal of failed step (#7144) --- internal/migration/command.go | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/internal/migration/command.go b/internal/migration/command.go index 5c18856697..49aaebdf92 100644 --- a/internal/migration/command.go +++ b/internal/migration/command.go @@ -2,7 +2,6 @@ package migration import ( "context" - "encoding/json" "github.com/zitadel/zitadel/internal/api/authz" "github.com/zitadel/zitadel/internal/api/service" @@ -15,25 +14,10 @@ type SetupStep struct { eventstore.BaseEvent `json:"-"` migration Migration Name string `json:"name"` - Error error `json:"error,omitempty"` + Error string `json:"error,omitempty"` LastRun interface{} `json:"lastRun,omitempty"` } -func (s *SetupStep) UnmarshalJSON(data []byte) error { - fields := struct { - Name string `json:"name,"` - Error *zerrors.ZitadelError `json:"error"` - LastRun map[string]interface{} `json:"lastRun,omitempty"` - }{} - if err := json.Unmarshal(data, &fields); err != nil { - return err - } - s.Name = fields.Name - s.Error = fields.Error - s.LastRun = fields.LastRun - return nil -} - func setupStartedCmd(ctx context.Context, migration Migration) eventstore.Command { ctx = authz.SetCtxData(service.WithService(ctx, "system"), authz.CtxData{UserID: "system", OrgID: "SYSTEM", ResourceOwner: "SYSTEM"}) return &SetupStep{ @@ -54,16 +38,16 @@ func setupDoneCmd(ctx context.Context, migration Migration, err error) eventstor typ = repeatableDoneType lastRun = repeatable } - if err != nil { - typ = failedType - } s := &SetupStep{ migration: migration, Name: migration.String(), - Error: err, LastRun: lastRun, } + if err != nil { + typ = failedType + s.Error = err.Error() + } s.BaseEvent = *eventstore.NewBaseEventForPush( ctx,