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

Commit

Permalink
use lib method
Browse files Browse the repository at this point in the history
Signed-off-by: Katrina Rogan <[email protected]>
  • Loading branch information
katrogan committed May 30, 2023
1 parent 3f1590c commit f8144c7
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions pkg/repositories/transformers/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ package transformers
import (
"context"
"fmt"
"strings"
"time"
"unicode/utf8"

"github.com/flyteorg/flyteadmin/pkg/common"
"github.com/flyteorg/flyteadmin/pkg/errors"
"github.com/flyteorg/flyteadmin/pkg/repositories/models"
Expand All @@ -17,6 +13,8 @@ import (
"github.com/flyteorg/flytestdlib/storage"
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/ptypes"
"strings"
"time"

"google.golang.org/grpc/codes"
"google.golang.org/protobuf/types/known/timestamppb"
Expand Down Expand Up @@ -412,12 +410,8 @@ func FromExecutionModels(ctx context.Context, executionModels []models.Execution

// TrimErrorMessage return the smallest possible trimmed error message >= trimmedErrMessageLen bytes in length that still forms a valid utf-8 string
func TrimErrorMessage(errMsg string) string {
if len(errMsg) < trimmedErrMessageLen {
if len(errMsg) <= trimmedErrMessageLen {
return errMsg
}
minLength := trimmedErrMessageLen
for len(errMsg) >= minLength && !utf8.ValidString(errMsg[:minLength]) {
minLength++
}
return errMsg[:minLength]
return strings.ToValidUTF8(errMsg[:trimmedErrMessageLen], "")
}

0 comments on commit f8144c7

Please sign in to comment.