Skip to content

Commit cbea408

Browse files
committed
fixing race condition in external go, ensure cmd has finished
Signed-off-by: Adam D. Cornett <[email protected]>
1 parent a405958 commit cbea408

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

internal/validate/external.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,17 @@ func RunExternalValidators(ctx context.Context, entrypoints []string, bundleRoot
6464
dec := json.NewDecoder(stdout)
6565
dec.DisallowUnknownFields()
6666

67-
if err := dec.Decode(&manifestresults[i]); err != nil {
68-
fmt.Printf("decode failed: %v\n", err)
69-
return nil, err
70-
}
67+
decodeErr := dec.Decode(&manifestresults[i])
68+
// Always wait for the command to finish to ensure stderr is fully written
69+
// and all goroutines complete before returning.
7170
if err := cmd.Wait(); err != nil {
7271
return nil, err
7372
}
73+
// Return decode error after waiting for command to complete
74+
if decodeErr != nil {
75+
fmt.Printf("decode failed: %v\n", decodeErr)
76+
return nil, decodeErr
77+
}
7478
}
7579
return manifestresults, nil
7680
}

0 commit comments

Comments
 (0)