From 46fee6c163a41069e13ba5dad6df5e188e989ca6 Mon Sep 17 00:00:00 2001 From: 1fanwang <1fannnw@gmail.com> Date: Wed, 10 Jun 2026 13:22:05 -0700 Subject: [PATCH] fix(flyteadmin): populate ErrorKind/ErrorCode columns for accept-time execution failures Signed-off-by: 1fanwang <1fannnw@gmail.com> --- .../pkg/repositories/transformers/execution.go | 13 +++++++++++++ .../repositories/transformers/execution_test.go | 14 ++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/flyteadmin/pkg/repositories/transformers/execution.go b/flyteadmin/pkg/repositories/transformers/execution.go index 8943d2303b..c25c48bde4 100644 --- a/flyteadmin/pkg/repositories/transformers/execution.go +++ b/flyteadmin/pkg/repositories/transformers/execution.go @@ -112,6 +112,17 @@ func CreateExecutionModel(input CreateExecutionModelInput) (*models.Execution, e activeExecution := int32(admin.ExecutionState_EXECUTION_ACTIVE) + // Populate the top-level ErrorKind/ErrorCode columns at create time so executions that + // fail before the propeller event path (e.g. accept-time validation failures) are + // queryable without deserializing the closure (mirrors UpdateExecutionModelState). + var errorKind, errorCode *string + if execErr := closure.GetError(); execErr != nil { + kind := execErr.GetKind().String() + code := execErr.GetCode() + errorKind = &kind + errorCode = &code + } + executionModel := &models.Execution{ ExecutionKey: models.ExecutionKey{ Project: input.WorkflowExecutionID.GetProject(), @@ -132,6 +143,8 @@ func CreateExecutionModel(input CreateExecutionModelInput) (*models.Execution, e User: requestSpec.GetMetadata().GetPrincipal(), State: &activeExecution, LaunchEntity: strings.ToLower(input.LaunchEntity.String()), + ErrorKind: errorKind, + ErrorCode: errorCode, } // A reference launch entity can be one of either or a task OR launch plan. Traditionally, workflows are executed // with a reference launch plan which is why this behavior is the default below. diff --git a/flyteadmin/pkg/repositories/transformers/execution_test.go b/flyteadmin/pkg/repositories/transformers/execution_test.go index 5ea50cefe4..dcde2b0069 100644 --- a/flyteadmin/pkg/repositories/transformers/execution_test.go +++ b/flyteadmin/pkg/repositories/transformers/execution_test.go @@ -113,6 +113,8 @@ func TestCreateExecutionModel(t *testing.T) { expectedSpecBytes, _ := proto.Marshal(expectedSpec) assert.Equal(t, expectedSpecBytes, execution.Spec) assert.Equal(t, execution.User, principal) + assert.Nil(t, execution.ErrorKind) + assert.Nil(t, execution.ErrorCode) expectedCreatedAt, _ := ptypes.TimestampProto(createdAt) expectedClosure, _ := proto.Marshal(&admin.ExecutionClosure{ @@ -172,6 +174,10 @@ func TestCreateExecutionModel(t *testing.T) { expectedSpecBytes, _ := proto.Marshal(expectedSpec) assert.Equal(t, expectedSpecBytes, execution.Spec) assert.Equal(t, execution.User, principal) + assert.NotNil(t, execution.ErrorKind) + assert.Equal(t, core.ExecutionError_SYSTEM.String(), *execution.ErrorKind) + assert.NotNil(t, execution.ErrorCode) + assert.Equal(t, "Unknown", *execution.ErrorCode) expectedCreatedAt, _ := ptypes.TimestampProto(createdAt) expectedClosure, _ := proto.Marshal(&admin.ExecutionClosure{ @@ -238,6 +244,10 @@ func TestCreateExecutionModel(t *testing.T) { expectedSpecBytes, _ := proto.Marshal(expectedSpec) assert.Equal(t, expectedSpecBytes, execution.Spec) assert.Equal(t, execution.User, principal) + assert.NotNil(t, execution.ErrorKind) + assert.Equal(t, core.ExecutionError_USER.String(), *execution.ErrorKind) + assert.NotNil(t, execution.ErrorCode) + assert.Equal(t, codes.InvalidArgument.String(), *execution.ErrorCode) expectedCreatedAt, _ := ptypes.TimestampProto(createdAt) expectedClosure, _ := proto.Marshal(&admin.ExecutionClosure{ @@ -304,6 +314,10 @@ func TestCreateExecutionModel(t *testing.T) { expectedSpecBytes, _ := proto.Marshal(expectedSpec) assert.Equal(t, expectedSpecBytes, execution.Spec) assert.Equal(t, execution.User, principal) + assert.NotNil(t, execution.ErrorKind) + assert.Equal(t, core.ExecutionError_SYSTEM.String(), *execution.ErrorKind) + assert.NotNil(t, execution.ErrorCode) + assert.Equal(t, codes.Internal.String(), *execution.ErrorCode) expectedCreatedAt, _ := ptypes.TimestampProto(createdAt) expectedClosure, _ := proto.Marshal(&admin.ExecutionClosure{