Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
Use ParseUint instead
Browse files Browse the repository at this point in the history
Signed-off-by: Haytham Abuelfutuh <[email protected]>
  • Loading branch information
EngHabu committed Jan 5, 2022
1 parent 2e7aa0e commit 7260a16
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions pkg/controller/nodes/task/catalog/datacatalog/transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"encoding/base64"
"fmt"
"math"
"reflect"
"strconv"
"strings"
Expand Down Expand Up @@ -213,19 +212,11 @@ func GetSourceFromMetadata(datasetMd, artifactMd *datacatalog.Metadata, currentI

// Jul-06-2020 DataCatalog stores only wfExecutionKey & taskVersionKey So we will default the project / domain to the current dataset's project domain
val := GetOrDefault(artifactMd.KeyMap, execTaskAttemptKey, "0")
attempt, err := strconv.Atoi(val)
attempt, err := strconv.ParseUint(val, 10, 32)
if err != nil {
return nil, fmt.Errorf("failed to parse [%v] to integer. Error: %w", val, err)
}

attempt32 := uint32(0)
// GOOD: check for lower and upper bounds
if attempt >= 0 && attempt <= math.MaxUint32 {
attempt32 = uint32(attempt)
} else {
return nil, fmt.Errorf("invalid attempts value [%v]", attempt)
}

return &core.TaskExecutionIdentifier{
TaskId: &core.Identifier{
ResourceType: currentID.ResourceType,
Expand All @@ -234,7 +225,7 @@ func GetSourceFromMetadata(datasetMd, artifactMd *datacatalog.Metadata, currentI
Name: currentID.Name,
Version: GetOrDefault(datasetMd.KeyMap, taskVersionKey, "unknown"),
},
RetryAttempt: attempt32,
RetryAttempt: uint32(attempt),
NodeExecutionId: &core.NodeExecutionIdentifier{
NodeId: GetOrDefault(artifactMd.KeyMap, execNodeIDKey, "unknown"),
ExecutionId: &core.WorkflowExecutionIdentifier{
Expand Down

0 comments on commit 7260a16

Please sign in to comment.