Skip to content

Commit

Permalink
Return error when skipping past all data
Browse files Browse the repository at this point in the history
  • Loading branch information
Micah-Kolide committed Mar 21, 2024
1 parent 2637d9c commit 95e92d8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ee/tables/execparsers/data_table/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package data_table

import (
"bufio"
"fmt"
"io"
"strings"
)
Expand Down Expand Up @@ -61,9 +62,9 @@ func (p parser) parseLines(reader io.Reader) ([]map[string]string, error) {
// This would likely only ever be 1 or 0, but we may want more.
for p.skipLines > 0 {
p.skipLines--
// Early exit if the scanner skipped past all data.

if !scanner.Scan() {
return results, nil // <-- Do we want to error here?
return results, fmt.Errorf("skipped past all lines of data")
}
}

Expand All @@ -86,7 +87,7 @@ func (p parser) parseLines(reader io.Reader) ([]map[string]string, error) {
min := min(headerCount, len(fields))

// For each header, add the corresponding line field to the result row.
// Duplicate headers overwrite the set value. <-- Perhaps this should be different?
// Duplicate headers overwrite the set value.
for i := 0; i < min; i++ {
row[strings.TrimSpace(p.headers[i])] = strings.TrimSpace(fields[i])
}
Expand Down

0 comments on commit 95e92d8

Please sign in to comment.