Skip to content

Commit

Permalink
Return InvalidArgument for workflow compilation failures in CreateWor…
Browse files Browse the repository at this point in the history
…kflow

Signed-off-by: Katrina Rogan <[email protected]>
  • Loading branch information
katrogan committed Dec 8, 2023
1 parent f440278 commit 2b7bde0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion flyteadmin/pkg/manager/impl/workflow_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (w *WorkflowManager) CreateWorkflow(
workflowClosure, err := w.getCompiledWorkflow(ctx, finalizedRequest)
if err != nil {
logger.Errorf(ctx, "Failed to compile workflow with err: %v", err)
return nil, errors.NewFlyteAdminErrorf(codes.Internal,
return nil, errors.NewFlyteAdminErrorf(codes.InvalidArgument,
"failed to compile workflow for [%+v] with err %v", request.Id, err)
}
err = validation.ValidateCompiledWorkflow(
Expand Down
6 changes: 5 additions & 1 deletion flyteadmin/pkg/manager/impl/workflow_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"google.golang.org/grpc/status"
"testing"

"github.com/golang/protobuf/proto"
Expand Down Expand Up @@ -243,10 +244,13 @@ func TestCreateWorkflow_CompileWorkflowError(t *testing.T) {
getMockWorkflowConfigProvider(), mockCompiler, getMockStorage(), storagePrefix, mockScope.NewTestScope())
request := testutils.GetWorkflowRequest()
response, err := workflowManager.CreateWorkflow(context.Background(), request)
assert.Nil(t, response)
s, ok := status.FromError(err)
assert.True(t, ok)
assert.Equal(t, codes.InvalidArgument, s.Code())
assert.EqualError(t, err, fmt.Sprintf(
"failed to compile workflow for [resource_type:WORKFLOW project:\"project\" domain:\"domain\" "+
"name:\"name\" version:\"version\" ] with err %v", expectedErr.Error()))
assert.Nil(t, response)
}

func TestCreateWorkflow_DatabaseError(t *testing.T) {
Expand Down

0 comments on commit 2b7bde0

Please sign in to comment.