diff --git a/go.mod b/go.mod index 85c1a0d4a..683e1e166 100644 --- a/go.mod +++ b/go.mod @@ -145,4 +145,4 @@ require ( sigs.k8s.io/yaml v1.3.0 // indirect ) -replace github.com/aws/amazon-sagemaker-operator-for-k8s => github.com/aws/amazon-sagemaker-operator-for-k8s v1.0.1-0.20210303003444-0fb33b1fd49d +replace github.com/aws/amazon-sagemaker-operator-for-k8s => github.com/aws/amazon-sagemaker-operator-for-k8s v1.0.1-0.20210303003444-0fb33b1fd49d \ No newline at end of file diff --git a/pkg/compiler/validators/bindings.go b/pkg/compiler/validators/bindings.go index 2942424fe..53b587796 100644 --- a/pkg/compiler/validators/bindings.go +++ b/pkg/compiler/validators/bindings.go @@ -125,6 +125,26 @@ func validateBinding(w c.WorkflowBuilder, nodeID c.NodeID, nodeParam string, bin } } + // If the type is a struct (e.g. dataclass) and the attribute path is longer than 0, + // We skip the type check and let it fail at runtime because we don't know the type of struct field + if sourceType.GetSimple() == flyte.SimpleType_STRUCT && len(val.Promise.AttrPath) > 0 { + return param.GetType(), []c.NodeID{val.Promise.NodeId}, true + } + + // If the variable has an attribute path. Extract the type of the last attribute. + for range val.Promise.AttrPath { + if sourceType.GetCollectionType() != nil { + sourceType = sourceType.GetCollectionType() + } + if sourceType.GetMapValueType() != nil { + sourceType = sourceType.GetMapValueType() + } + // If the current type is struct, skip the type check because we don't know the type of struct field + if sourceType.GetSimple() == flyte.SimpleType_STRUCT { + return param.GetType(), []c.NodeID{val.Promise.NodeId}, true + } + } + if !validateParamTypes || AreTypesCastable(sourceType, expectedType) { val.Promise.NodeId = upNode.GetId() return param.GetType(), []c.NodeID{val.Promise.NodeId}, true diff --git a/pkg/compiler/validators/bindings_test.go b/pkg/compiler/validators/bindings_test.go index f240cf1d8..48f0afd22 100644 --- a/pkg/compiler/validators/bindings_test.go +++ b/pkg/compiler/validators/bindings_test.go @@ -4,6 +4,7 @@ import ( "testing" c "github.com/flyteorg/flytepropeller/pkg/compiler/common" + structpb "github.com/golang/protobuf/ptypes/struct" "github.com/flyteorg/flyteidl/clients/go/coreutils" "github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/core" @@ -305,6 +306,150 @@ func TestValidateBindings(t *testing.T) { } }) + t.Run("List/Dict Promises with attribute path", func(t *testing.T) { + // List/Dict with attribute path should conduct validation + + n := &mocks.NodeBuilder{} + n.OnGetId().Return("node1") + n.OnGetInterface().Return(&core.TypedInterface{ + Inputs: &core.VariableMap{ + Variables: map[string]*core.Variable{}, + }, + Outputs: &core.VariableMap{ + Variables: map[string]*core.Variable{}, + }, + }) + + n2 := &mocks.NodeBuilder{} + n2.OnGetId().Return("node2") + n2.OnGetOutputAliases().Return(nil) + n2.OnGetInterface().Return(&core.TypedInterface{ + Inputs: &core.VariableMap{ + Variables: map[string]*core.Variable{}, + }, + Outputs: &core.VariableMap{ + Variables: map[string]*core.Variable{ + "n2_out": { + Type: LiteralTypeForLiteral(coreutils.MustMakeLiteral(map[string]interface{}{"x": []interface{}{1, 3, 4}})), + }, + }, + }, + }) + + wf := &mocks.WorkflowBuilder{} + wf.OnGetNode("n2").Return(n2, true) + wf.On("AddExecutionEdge", mock.Anything, mock.Anything).Return(nil) + + bindings := []*core.Binding{ + { + Var: "x", + Binding: &core.BindingData{ + Value: &core.BindingData_Promise{ + Promise: &core.OutputReference{ + Var: "n2_out", + NodeId: "n2", + AttrPath: []*core.PromiseAttribute{ + { + Value: &core.PromiseAttribute_StringValue{"x"}, + }, + { + Value: &core.PromiseAttribute_IntValue{0}, + }, + }, + }, + }, + }, + }, + } + + vars := &core.VariableMap{ + Variables: map[string]*core.Variable{ + "x": { + Type: LiteralTypeForLiteral(coreutils.MustMakeLiteral(1)), + }, + }, + } + + compileErrors := compilerErrors.NewCompileErrors() + _, ok := ValidateBindings(wf, n, bindings, vars, true, c.EdgeDirectionBidirectional, compileErrors) + assert.True(t, ok) + if compileErrors.HasErrors() { + assert.NoError(t, compileErrors) + } + }) + + t.Run("pb.Struct Promises with attribute path", func(t *testing.T) { + // Dataclass with attribute path should skip validation + + n := &mocks.NodeBuilder{} + n.OnGetId().Return("node1") + n.OnGetInterface().Return(&core.TypedInterface{ + Inputs: &core.VariableMap{ + Variables: map[string]*core.Variable{}, + }, + Outputs: &core.VariableMap{ + Variables: map[string]*core.Variable{}, + }, + }) + + n2 := &mocks.NodeBuilder{} + n2.OnGetId().Return("node2") + n2.OnGetOutputAliases().Return(nil) + n2.OnGetInterface().Return(&core.TypedInterface{ + Inputs: &core.VariableMap{ + Variables: map[string]*core.Variable{}, + }, + Outputs: &core.VariableMap{ + Variables: map[string]*core.Variable{ + "n2_out": { + Type: LiteralTypeForLiteral(coreutils.MustMakeLiteral(&structpb.Struct{})), + }, + }, + }, + }) + + wf := &mocks.WorkflowBuilder{} + wf.OnGetNode("n2").Return(n2, true) + wf.On("AddExecutionEdge", mock.Anything, mock.Anything).Return(nil) + + bindings := []*core.Binding{ + { + Var: "x", + Binding: &core.BindingData{ + Value: &core.BindingData_Promise{ + Promise: &core.OutputReference{ + Var: "n2_out", + NodeId: "n2", + AttrPath: []*core.PromiseAttribute{ + { + Value: &core.PromiseAttribute_StringValue{"x"}, + }, + { + Value: &core.PromiseAttribute_IntValue{0}, + }, + }, + }, + }, + }, + }, + } + + vars := &core.VariableMap{ + Variables: map[string]*core.Variable{ + "x": { + Type: LiteralTypeForLiteral(coreutils.MustMakeLiteral(1)), + }, + }, + } + + compileErrors := compilerErrors.NewCompileErrors() + _, ok := ValidateBindings(wf, n, bindings, vars, true, c.EdgeDirectionBidirectional, compileErrors) + assert.True(t, ok) + if compileErrors.HasErrors() { + assert.NoError(t, compileErrors) + } + }) + t.Run("Nil Binding Value", func(t *testing.T) { n := &mocks.NodeBuilder{} n.OnGetId().Return("node1") diff --git a/pkg/controller/nodes/attr_path_resolver.go b/pkg/controller/nodes/attr_path_resolver.go new file mode 100644 index 000000000..a894d1f6f --- /dev/null +++ b/pkg/controller/nodes/attr_path_resolver.go @@ -0,0 +1,156 @@ +package nodes + +import ( + "context" + + "github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/core" + "github.com/flyteorg/flytepropeller/pkg/controller/nodes/errors" + "google.golang.org/protobuf/types/known/structpb" +) + +// resolveAttrPathInPromise resolves the literal with attribute path +// If the promise is chained with attributes (e.g. promise.a["b"][0]), then we need to resolve the promise +func resolveAttrPathInPromise(ctx context.Context, nodeID string, literal *core.Literal, bindAttrPath []*core.PromiseAttribute) (*core.Literal, error) { + var currVal *core.Literal = literal + var tmpVal *core.Literal + var err error + var exist bool + count := 0 + + for _, attr := range bindAttrPath { + switch currVal.GetValue().(type) { + case *core.Literal_Map: + tmpVal, exist = currVal.GetMap().GetLiterals()[attr.GetStringValue()] + if exist == false { + return nil, errors.Errorf(errors.PromiseAttributeResolveError, nodeID, "key [%v] does not exist in literal %v", attr.GetStringValue(), currVal.GetMap().GetLiterals()) + } + currVal = tmpVal + count += 1 + case *core.Literal_Collection: + if int(attr.GetIntValue()) >= len(currVal.GetCollection().GetLiterals()) { + return nil, errors.Errorf(errors.PromiseAttributeResolveError, nodeID, "index [%v] is out of range of %v", attr.GetIntValue(), currVal.GetCollection().GetLiterals()) + } + currVal = currVal.GetCollection().GetLiterals()[attr.GetIntValue()] + count += 1 + // scalar is always the leaf, so we can break here + case *core.Literal_Scalar: + break + } + } + + // resolve dataclass + if currVal.GetScalar() != nil && currVal.GetScalar().GetGeneric() != nil { + st := currVal.GetScalar().GetGeneric() + // start from index "count" + currVal, err = resolveAttrPathInPbStruct(ctx, nodeID, st, bindAttrPath[count:]) + if err != nil { + return nil, err + } + } + + return currVal, nil +} + +// resolveAttrPathInPbStruct resolves the protobuf struct (e.g. dataclass) with attribute path +func resolveAttrPathInPbStruct(ctx context.Context, nodeID string, st *structpb.Struct, bindAttrPath []*core.PromiseAttribute) (*core.Literal, error) { + + var currVal interface{} + var tmpVal interface{} + var exist bool + + currVal = st.AsMap() + + // Turn the current value to a map so it can be resolved more easily + for _, attr := range bindAttrPath { + switch currVal.(type) { + // map + case map[string]interface{}: + tmpVal, exist = currVal.(map[string]interface{})[attr.GetStringValue()] + if exist == false { + return nil, errors.Errorf(errors.PromiseAttributeResolveError, nodeID, "key [%v] does not exist in literal %v", attr.GetStringValue(), currVal) + } + currVal = tmpVal + // list + case []interface{}: + if int(attr.GetIntValue()) >= len(currVal.([]interface{})) { + return nil, errors.Errorf(errors.PromiseAttributeResolveError, nodeID, "index [%v] is out of range of %v", attr.GetIntValue(), currVal) + } + currVal = currVal.([]interface{})[attr.GetIntValue()] + } + } + + // After resolve, convert the interface to literal + literal, err := convertInterfaceToLiteral(ctx, nodeID, currVal) + + return literal, err +} + +// convertInterfaceToLiteral converts the protobuf struct (e.g. dataclass) to literal +func convertInterfaceToLiteral(ctx context.Context, nodeID string, obj interface{}) (*core.Literal, error) { + + literal := &core.Literal{} + + switch obj.(type) { + case map[string]interface{}: + new_st, err := structpb.NewStruct(obj.(map[string]interface{})) + if err != nil { + return nil, err + } + literal.Value = &core.Literal_Scalar{ + Scalar: &core.Scalar{ + Value: &core.Scalar_Generic{ + Generic: new_st, + }, + }, + } + case []interface{}: + literals := []*core.Literal{} + for _, v := range obj.([]interface{}) { + // recursively convert the interface to literal + literal, err := convertInterfaceToLiteral(ctx, nodeID, v) + if err != nil { + return nil, err + } + literals = append(literals, literal) + } + literal.Value = &core.Literal_Collection{ + Collection: &core.LiteralCollection{ + Literals: literals, + }, + } + case interface{}: + scalar, err := convertInterfaceToLiteralScalar(ctx, nodeID, obj) + if err != nil { + return nil, err + } + literal.Value = scalar + } + + return literal, nil +} + +// convertInterfaceToLiteralScalar converts the a single value to a literal scalar +func convertInterfaceToLiteralScalar(ctx context.Context, nodeID string, obj interface{}) (*core.Literal_Scalar, error) { + value := &core.Primitive{} + + switch obj.(type) { + case string: + value.Value = &core.Primitive_StringValue{StringValue: obj.(string)} + case int: + value.Value = &core.Primitive_Integer{Integer: int64(obj.(int))} + case float64: + value.Value = &core.Primitive_FloatValue{FloatValue: obj.(float64)} + case bool: + value.Value = &core.Primitive_Boolean{Boolean: obj.(bool)} + default: + return nil, errors.Errorf(errors.PromiseAttributeResolveError, nodeID, "Failed to resolve interface to literal scalar") + } + + return &core.Literal_Scalar{ + Scalar: &core.Scalar{ + Value: &core.Scalar_Primitive{ + Primitive: value, + }, + }, + }, nil +} diff --git a/pkg/controller/nodes/attr_path_resolver_test.go b/pkg/controller/nodes/attr_path_resolver_test.go new file mode 100644 index 000000000..3096ef603 --- /dev/null +++ b/pkg/controller/nodes/attr_path_resolver_test.go @@ -0,0 +1,329 @@ +package nodes + +import ( + "testing" + + "github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/core" + "github.com/flyteorg/flytepropeller/pkg/controller/nodes/errors" + "github.com/stretchr/testify/assert" + "google.golang.org/protobuf/types/known/structpb" +) + +func NewScalarLiteral(value string) *core.Literal { + return &core.Literal{ + Value: &core.Literal_Scalar{ + Scalar: &core.Scalar{ + Value: &core.Scalar_Primitive{ + Primitive: &core.Primitive{ + Value: &core.Primitive_StringValue{ + StringValue: value, + }, + }, + }, + }, + }, + } +} + +func NewStructFromMap(m map[string]interface{}) *structpb.Struct { + st, _ := structpb.NewStruct(m) + return st +} + +func TestResolveAttrPathIn(t *testing.T) { + // - map {"foo": "bar"} + // - collection ["foo", "bar"] + // - struct1 {"foo": "bar"} + // - struct2 {"foo": ["bar1", "bar2"]} + // - nested list struct {"foo": [["bar1", "bar2"]]} + // - map+collection+struct {"foo": [{"bar": "car"}]} + // - exception key error with map + // - exception out of range with collection + // - exception key error with struct + // - exception out of range with struct + + args := []struct { + literal *core.Literal + path []*core.PromiseAttribute + expected *core.Literal + hasError bool + }{ + { + literal: &core.Literal{ + Value: &core.Literal_Map{ + Map: &core.LiteralMap{ + Literals: map[string]*core.Literal{ + "foo": NewScalarLiteral("bar"), + }, + }, + }, + }, + path: []*core.PromiseAttribute{ + &core.PromiseAttribute{ + Value: &core.PromiseAttribute_StringValue{ + StringValue: "foo", + }, + }, + }, + expected: NewScalarLiteral("bar"), + hasError: false, + }, + { + literal: &core.Literal{ + Value: &core.Literal_Collection{ + Collection: &core.LiteralCollection{ + Literals: []*core.Literal{ + NewScalarLiteral("foo"), + NewScalarLiteral("bar"), + }, + }, + }, + }, + path: []*core.PromiseAttribute{ + &core.PromiseAttribute{ + Value: &core.PromiseAttribute_IntValue{ + IntValue: 1, + }, + }, + }, + expected: NewScalarLiteral("bar"), + hasError: false, + }, + { + literal: &core.Literal{ + Value: &core.Literal_Scalar{ + Scalar: &core.Scalar{ + Value: &core.Scalar_Generic{ + Generic: NewStructFromMap(map[string]interface{}{"foo": "bar"}), + }, + }, + }, + }, + path: []*core.PromiseAttribute{ + &core.PromiseAttribute{ + Value: &core.PromiseAttribute_StringValue{ + StringValue: "foo", + }, + }, + }, + expected: NewScalarLiteral("bar"), + hasError: false, + }, + { + literal: &core.Literal{ + Value: &core.Literal_Scalar{ + Scalar: &core.Scalar{ + Value: &core.Scalar_Generic{ + Generic: NewStructFromMap( + map[string]interface{}{ + "foo": []interface{}{"bar1", "bar2"}, + }, + ), + }, + }, + }, + }, + path: []*core.PromiseAttribute{ + &core.PromiseAttribute{ + Value: &core.PromiseAttribute_StringValue{ + StringValue: "foo", + }, + }, + &core.PromiseAttribute{ + Value: &core.PromiseAttribute_IntValue{ + IntValue: 1, + }, + }, + }, + expected: NewScalarLiteral("bar2"), + hasError: false, + }, + { + literal: &core.Literal{ + Value: &core.Literal_Scalar{ + Scalar: &core.Scalar{ + Value: &core.Scalar_Generic{ + Generic: NewStructFromMap( + map[string]interface{}{ + "foo": []interface{}{[]interface{}{"bar1", "bar2"}}, + }, + ), + }, + }, + }, + }, + path: []*core.PromiseAttribute{ + &core.PromiseAttribute{ + Value: &core.PromiseAttribute_StringValue{ + StringValue: "foo", + }, + }, + }, + expected: &core.Literal{ + Value: &core.Literal_Collection{ + Collection: &core.LiteralCollection{ + Literals: []*core.Literal{ + &core.Literal{ + Value: &core.Literal_Collection{ + Collection: &core.LiteralCollection{ + Literals: []*core.Literal{ + NewScalarLiteral("bar1"), + NewScalarLiteral("bar2"), + }, + }, + }, + }, + }, + }, + }, + }, + hasError: false, + }, + { + literal: &core.Literal{ + Value: &core.Literal_Map{ + Map: &core.LiteralMap{ + Literals: map[string]*core.Literal{ + "foo": &core.Literal{ + Value: &core.Literal_Collection{ + Collection: &core.LiteralCollection{ + Literals: []*core.Literal{ + &core.Literal{ + Value: &core.Literal_Scalar{ + Scalar: &core.Scalar{ + Value: &core.Scalar_Generic{ + Generic: NewStructFromMap(map[string]interface{}{"bar": "car"}), + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + path: []*core.PromiseAttribute{ + &core.PromiseAttribute{ + Value: &core.PromiseAttribute_StringValue{ + StringValue: "foo", + }, + }, + &core.PromiseAttribute{ + Value: &core.PromiseAttribute_IntValue{ + IntValue: 0, + }, + }, + &core.PromiseAttribute{ + Value: &core.PromiseAttribute_StringValue{ + StringValue: "bar", + }, + }, + }, + expected: NewScalarLiteral("car"), + hasError: false, + }, + { + literal: &core.Literal{ + Value: &core.Literal_Map{ + Map: &core.LiteralMap{ + Literals: map[string]*core.Literal{ + "foo": NewScalarLiteral("bar"), + }, + }, + }, + }, + path: []*core.PromiseAttribute{ + &core.PromiseAttribute{ + Value: &core.PromiseAttribute_StringValue{ + StringValue: "random", + }, + }, + }, + expected: &core.Literal{}, + hasError: true, + }, + { + literal: &core.Literal{ + Value: &core.Literal_Collection{ + Collection: &core.LiteralCollection{ + Literals: []*core.Literal{ + NewScalarLiteral("foo"), + NewScalarLiteral("bar"), + }, + }, + }, + }, + path: []*core.PromiseAttribute{ + &core.PromiseAttribute{ + Value: &core.PromiseAttribute_IntValue{ + IntValue: 2, + }, + }, + }, + expected: &core.Literal{}, + hasError: true, + }, + { + literal: &core.Literal{ + Value: &core.Literal_Scalar{ + Scalar: &core.Scalar{ + Value: &core.Scalar_Generic{ + Generic: NewStructFromMap(map[string]interface{}{"foo": "bar"}), + }, + }, + }, + }, + path: []*core.PromiseAttribute{ + &core.PromiseAttribute{ + Value: &core.PromiseAttribute_StringValue{ + StringValue: "random", + }, + }, + }, + expected: &core.Literal{}, + hasError: true, + }, + { + literal: &core.Literal{ + Value: &core.Literal_Scalar{ + Scalar: &core.Scalar{ + Value: &core.Scalar_Generic{ + Generic: NewStructFromMap( + map[string]interface{}{ + "foo": []interface{}{"bar1", "bar2"}, + }, + ), + }, + }, + }, + }, + path: []*core.PromiseAttribute{ + &core.PromiseAttribute{ + Value: &core.PromiseAttribute_StringValue{ + StringValue: "foo", + }, + }, + &core.PromiseAttribute{ + Value: &core.PromiseAttribute_IntValue{ + IntValue: 100, + }, + }, + }, + expected: &core.Literal{}, + hasError: true, + }, + } + + for i, arg := range args { + resolved, err := resolveAttrPathInPromise(nil, "", arg.literal, arg.path) + if arg.hasError { + assert.Error(t, err, i) + assert.ErrorContains(t, err, errors.PromiseAttributeResolveError, i) + } else { + assert.Equal(t, arg.expected, resolved, i) + } + } +} diff --git a/pkg/controller/nodes/errors/codes.go b/pkg/controller/nodes/errors/codes.go index 30ded68b7..100ccdc77 100644 --- a/pkg/controller/nodes/errors/codes.go +++ b/pkg/controller/nodes/errors/codes.go @@ -26,4 +26,5 @@ const ( EventRecordingFailed ErrorCode = "EventRecordingFailed" CatalogCallFailed ErrorCode = "CatalogCallFailed" InvalidArrayLength ErrorCode = "InvalidArrayLength" + PromiseAttributeResolveError ErrorCode = "PromiseAttributeResolveError" ) diff --git a/pkg/controller/nodes/output_resolver.go b/pkg/controller/nodes/output_resolver.go index 219ca09fe..e71d3d9c5 100644 --- a/pkg/controller/nodes/output_resolver.go +++ b/pkg/controller/nodes/output_resolver.go @@ -22,7 +22,7 @@ type VarName = string type OutputResolver interface { // Extracts a subset of node outputs to literals. ExtractOutput(ctx context.Context, nl executors.NodeLookup, n v1alpha1.ExecutableNode, - bindToVar VarName) (values *core.Literal, err error) + bindToVar VarName, bindAttrPath []*core.PromiseAttribute) (values *core.Literal, err error) } func CreateAliasMap(aliases []v1alpha1.Alias) map[string]string { @@ -39,7 +39,7 @@ type remoteFileOutputResolver struct { } func (r remoteFileOutputResolver) ExtractOutput(ctx context.Context, nl executors.NodeLookup, n v1alpha1.ExecutableNode, - bindToVar VarName) (values *core.Literal, err error) { + bindToVar VarName, bindAttrPath []*core.PromiseAttribute) (values *core.Literal, err error) { nodeStatus := nl.GetNodeExecutionStatus(ctx, n.GetID()) outputsFileRef := v1alpha1.GetOutputsFile(nodeStatus.GetOutputDir()) @@ -54,11 +54,25 @@ func (r remoteFileOutputResolver) ExtractOutput(ctx context.Context, nl executor actualVar = variable } + var output *core.Literal + + // retrieving task output if index == nil { - return resolveSingleOutput(ctx, r.store, n.GetID(), outputsFileRef, actualVar) + output, err = resolveSingleOutput(ctx, r.store, n.GetID(), outputsFileRef, actualVar) + } else { + output, err = resolveSubtaskOutput(ctx, r.store, n.GetID(), outputsFileRef, *index, actualVar) + } + + if err != nil { + return nil, err + } + + // resolving binding attribute path if exist + if len(bindAttrPath) > 0 { + output, err = resolveAttrPathInPromise(ctx, n.GetID(), output, bindAttrPath) } - return resolveSubtaskOutput(ctx, r.store, n.GetID(), outputsFileRef, *index, actualVar) + return output, err } func resolveSubtaskOutput(ctx context.Context, store storage.ProtobufStore, nodeID string, outputsFileRef storage.DataReference, diff --git a/pkg/controller/nodes/resolve.go b/pkg/controller/nodes/resolve.go index 4ad66c955..800427b4c 100644 --- a/pkg/controller/nodes/resolve.go +++ b/pkg/controller/nodes/resolve.go @@ -61,6 +61,7 @@ func ResolveBindingData(ctx context.Context, outputResolver OutputResolver, nl e upstreamNodeID := bindingData.GetPromise().GetNodeId() bindToVar := bindingData.GetPromise().GetVar() + bindAttrPath := bindingData.GetPromise().GetAttrPath() if nl == nil { return nil, errors.Errorf(errors.IllegalStateError, upstreamNodeID, @@ -79,7 +80,7 @@ func ResolveBindingData(ctx context.Context, outputResolver OutputResolver, nl e "Undefined node in Workflow") } - return outputResolver.ExtractOutput(ctx, nl, n, bindToVar) + return outputResolver.ExtractOutput(ctx, nl, n, bindToVar, bindAttrPath) case *core.BindingData_Scalar: logger.Debugf(ctx, "bindingData.GetValue() [%v] is of type Scalar", bindingData.GetValue()) literal.Value = &core.Literal_Scalar{Scalar: bindingData.GetScalar()}