code: func controllerForInvocation(c context.Context, e *engineImpl, inv *Invocation) (*taskController, error) {
  	ctl := &taskController{
  		ctx:   c,
  		eng:   e,
  		saved: *inv,
  	}
  	var err error
  	if ctl.task, err = e.cfg.Catalog.UnmarshalTask(c, inv.Task); err != nil {
  		return ctl, fmt.Errorf("failed to unmarshal the task - %s", err)
  	}
  	if ctl.manager = e.cfg.Catalog.GetTaskManager(ctl.task); ctl.manager == nil {
  		return ctl, fmt.Errorf("TaskManager is unexpectedly missing")
  	}
  	if err = ctl.populateState(); err != nil {
  		return ctl, fmt.Errorf("failed to construct task.State - %s", err)
  	}
  	if ctl.request, err = getRequestFromInv(&ctl.saved); err != nil {
  		return ctl, fmt.Errorf("failed to construct task.Request - %s", err)
  	}
  	return ctl, nil
  }
docs: // controllerForInvocation returns new instance of taskController configured
  // to work with given invocation.
  //
  // If task definition can't be deserialized, returns both controller and error.