Skip to content

Commit

Permalink
model/task: fixe incorrect task data field unmarshal
Browse files Browse the repository at this point in the history
Set a matching JSON struct tag and create map if nil
  • Loading branch information
joelrebel committed Aug 26, 2024
1 parent ba55138 commit 51fd93b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/model/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ type TaskData struct {
ActionsPlanned Actions `json:"actions_planned,omitempty"`

// Scratch is an arbitrary key values map available to all task, action handler methods.
Scratch map[string]string `json:"data,omitempty"`
Scratch map[string]string `json:"scratch,omitempty"`
}

func (td *TaskData) MapStringInterfaceToStruct(m map[string]interface{}) error {
Expand Down Expand Up @@ -172,6 +172,10 @@ func convTaskData(data any) (*TaskData, error) {
return nil, errors.Wrap(errDataConv, msg)
}

if taskData.Scratch == nil {
taskData.Scratch = map[string]string{}
}

return taskData, nil
}

Expand Down

0 comments on commit 51fd93b

Please sign in to comment.