Skip to content

Commit 7f4c07d

Browse files
committed
fix: e2e: validate inputData during log postprocessing to avoid panic
1 parent 4b1dd04 commit 7f4c07d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

test/e2e/shared/common.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,11 @@ func postProcessBase64LogData(dir, src, dst string) error {
312312
}
313313

314314
// Extract second line which contains the data (first line contains the command)
315-
inputStringData := strings.Split(string(inputData), "\n")[1]
315+
inputDataLines := strings.Split(string(inputData), "\n")
316+
if len(inputDataLines) < 2 {
317+
return errors.Errorf("source file %q does not contain expected data (need at least 2 lines, got %d), input data content: %q", sourceFile, len(inputDataLines), string(inputData))
318+
}
319+
inputStringData := inputDataLines[1]
316320

317321
// Trim spaces and the $ suffix.
318322
inputStringData = strings.TrimSpace(inputStringData)

0 commit comments

Comments
 (0)