Skip to content

Commit

Permalink
nit
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Su <[email protected]>
  • Loading branch information
pingsutw committed Sep 25, 2024
1 parent 6e6d449 commit 267852b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions flytepropeller/pkg/controller/nodes/attr_path_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func resolveAttrPathInPromise(nodeID string, literal *core.Literal, bindAttrPath
var tmpVal *core.Literal
var err error
var exist bool
count := 0
index := 0

for _, attr := range bindAttrPath {
switch currVal.GetValue().(type) {
Expand All @@ -27,13 +27,13 @@ func resolveAttrPathInPromise(nodeID string, literal *core.Literal, bindAttrPath
return nil, errors.Errorf(errors.PromiseAttributeResolveError, nodeID, "key [%v] does not exist in literal %v", attr.GetStringValue(), currVal.GetMap().GetLiterals())
}
currVal = tmpVal
count++
index++
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++
index++
// scalar is always the leaf, so we can break here
case *core.Literal_Scalar:
break
Expand All @@ -43,12 +43,12 @@ func resolveAttrPathInPromise(nodeID string, literal *core.Literal, bindAttrPath
// resolve dataclass and Pydantic BaseModel
if scalar := currVal.GetScalar(); scalar != nil {
if binary := scalar.GetBinary(); binary != nil {
currVal, err = resolveAttrPathInBinary(nodeID, binary, bindAttrPath[count:])
currVal, err = resolveAttrPathInBinary(nodeID, binary, bindAttrPath[index:])
if err != nil {
return nil, err
}
} else if generic := scalar.GetGeneric(); generic != nil {
currVal, err = resolveAttrPathInPbStruct(nodeID, generic, bindAttrPath[count:])
currVal, err = resolveAttrPathInPbStruct(nodeID, generic, bindAttrPath[index:])
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 267852b

Please sign in to comment.