@@ -10,6 +10,8 @@ import (
1010 "github.com/flyteorg/flyteplugins/go/tasks/errors"
1111 "github.com/flyteorg/flyteplugins/go/tasks/logs"
1212 "github.com/flyteorg/flyteplugins/go/tasks/pluginmachinery/core"
13+ "github.com/flyteorg/flyteplugins/go/tasks/pluginmachinery/io"
14+ "github.com/flyteorg/flyteplugins/go/tasks/pluginmachinery/ioutils"
1315 "github.com/flyteorg/flyteplugins/go/tasks/plugins/array"
1416 "github.com/flyteorg/flyteplugins/go/tasks/plugins/array/arraystatus"
1517 arrayCore "github.com/flyteorg/flyteplugins/go/tasks/plugins/array/core"
@@ -211,6 +213,30 @@ func LaunchAndCheckSubTasksState(ctx context.Context, tCtx core.TaskExecutionCon
211213
212214 if phaseInfo .Err () != nil {
213215 messageCollector .Collect (childIdx , phaseInfo .Err ().String ())
216+
217+ // If the service reported an error but there is no error.pb written, write one with the
218+ // service-provided error message.
219+ or , err := array .ConstructOutputReader (ctx , dataStore , outputPrefix , baseOutputDataSandbox , originalIdx )
220+ if err != nil {
221+ return currentState , externalResources , err
222+ }
223+
224+ if hasErr , err := or .IsError (ctx ); err != nil {
225+ return currentState , externalResources , err
226+ } else if ! hasErr {
227+ // The subtask has not produced an error.pb, write one.
228+ ow , err := array .ConstructOutputWriter (ctx , dataStore , outputPrefix , baseOutputDataSandbox , originalIdx )
229+ if err != nil {
230+ return currentState , externalResources , err
231+ }
232+
233+ if err = ow .Put (ctx , ioutils .NewInMemoryOutputReader (nil , & io.ExecutionError {
234+ ExecutionError : phaseInfo .Err (),
235+ IsRecoverable : phaseInfo .Phase () != core .PhasePermanentFailure ,
236+ })); err != nil {
237+ return currentState , externalResources , err
238+ }
239+ }
214240 }
215241
216242 if phaseInfo .Err () != nil && phaseInfo .Err ().GetKind () == idlCore .ExecutionError_SYSTEM {
@@ -250,10 +276,6 @@ func LaunchAndCheckSubTasksState(ctx context.Context, tCtx core.TaskExecutionCon
250276 }
251277
252278 // process phaseInfo
253- if phaseInfo .Err () != nil {
254- messageCollector .Collect (childIdx , phaseInfo .Err ().String ())
255- }
256-
257279 var logLinks []* idlCore.TaskLog
258280 if phaseInfo .Info () != nil {
259281 logLinks = phaseInfo .Info ().Logs
0 commit comments