Skip to content

Commit

Permalink
fix: fix the component render error was not being returned (#707)
Browse files Browse the repository at this point in the history
Because

- The component render error was not being returned.

This commit

- Fixes the bug.
  • Loading branch information
donch1989 authored Oct 6, 2024
1 parent 75a757b commit 931f067
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions pkg/component/base/execution_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ func (e *ExecutionWrapper) Execute(ctx context.Context, jobs []*Job) (err error)
inputs := make([]*structpb.Struct, len(jobs))
outputs := make([]*structpb.Struct, len(jobs))

validInputs := make([]*structpb.Struct, 0, len(jobs))
validJobs := make([]*Job, 0, len(jobs))
validJobIdx := make([]int, 0, len(jobs))

// Note: We need to check usage of all inputs simultaneously, so all inputs
// must be read before execution.
for batchIdx, job := range jobs {
Expand All @@ -84,16 +88,19 @@ func (e *ExecutionWrapper) Execute(ctx context.Context, jobs []*Job) (err error)
job.Error.Error(ctx, err)
continue
}
validInputs = append(validInputs, inputs[batchIdx])
validJobs = append(validJobs, job)
validJobIdx = append(validJobIdx, batchIdx)
}

if err = h.Check(ctx, inputs); err != nil {
return err
}

wrappedJobs := make([]*Job, len(jobs))
for batchIdx, job := range jobs {
wrappedJobs := make([]*Job, len(validJobs))
for batchIdx, job := range validJobs {
wrappedJobs[batchIdx] = &Job{
Input: NewInputReader(inputs[batchIdx], e.GetTaskInputSchema()),
Input: NewInputReader(validInputs[batchIdx], e.GetTaskInputSchema()),
Output: NewOutputWriter(job.Output, e.GetTaskOutputSchema()),
Error: job.Error,
}
Expand All @@ -106,7 +113,7 @@ func (e *ExecutionWrapper) Execute(ctx context.Context, jobs []*Job) (err error)
// Since there might be multiple writes, we collect the usage at the end of
// the execution.​
for batchIdx, job := range wrappedJobs {
outputs[batchIdx] = job.Output.(*outputWriter).GetOutput()
outputs[validJobIdx[batchIdx]] = job.Output.(*outputWriter).GetOutput()
}
if err := h.Collect(ctx, inputs, outputs); err != nil {
return err
Expand Down

0 comments on commit 931f067

Please sign in to comment.