Skip to content

Commit

Permalink
updated context input key
Browse files Browse the repository at this point in the history
  • Loading branch information
adranwit committed Aug 26, 2024
1 parent b7b7340 commit 27b0c82
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions service/operator/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (s *Service) HandleError(ctx context.Context, aSession *session.Session, aC
}

}
if ! aComponent.Output.Type.Parameters.HasErrorParameter() {
if !aComponent.Output.Type.Parameters.HasErrorParameter() {
return nil, err
}
output := aComponent.Output.Type.Type().NewState()
Expand Down Expand Up @@ -141,12 +141,17 @@ func (s *Service) EnsureInput(ctx context.Context, aComponent *repository.Compon
if inputType := aComponent.Input.Type; inputType.Type() != nil {
var inputState *structology.State
input := ctx.Value(xhandler.InputKey)
hasInputKey := input != nil
if input != nil {
inputState = inputType.Type().WithValue(input)
if reflect.TypeOf(input).AssignableTo(inputType.Type().Type()) {
inputState = inputType.Type().WithValue(input)
} else {
input = nil
inputState = inputType.Type().NewState()
}
} else {
inputState = inputType.Type().NewState()
}

locatorOptions := aComponent.LocatorOptions(nil, nil, nil)
options := aSession.ViewOptions(aComponent.View, session.WithLocatorOptions(locatorOptions...))
options = options.Indirect(true)
Expand All @@ -170,7 +175,9 @@ func (s *Service) EnsureInput(ctx context.Context, aComponent *repository.Compon
return nil, err
}
}
ctx = context.WithValue(ctx, xhandler.InputKey, anInput)
if !hasInputKey {
ctx = context.WithValue(ctx, xhandler.InputKey, anInput)
}
ctx = context.WithValue(ctx, reflect.TypeOf(anInput), anInput)
}
}
Expand Down

0 comments on commit 27b0c82

Please sign in to comment.