Skip to content

Commit

Permalink
fix: fixes log parser (#3398)
Browse files Browse the repository at this point in the history
  • Loading branch information
pilat authored Nov 16, 2024
1 parent 56a2ab1 commit 80d502e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/docker/logfmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func ParseLogFmt(log string) (*orderedmap.OrderedMap[string, string], error) {
char := log[i]
if isKey {
if char == '=' {
if i == start {
if start >= i {
return nil, errors.New("invalid format: key is empty")
}
key = log[start:i]
Expand Down
6 changes: 6 additions & 0 deletions internal/docker/logfmt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ func TestParseLog(t *testing.T) {
),
wantErr: false,
},
{
name: "Broken format with unexpected quotes",
log: `key1=value"1"= key2="value2"`,
want: nil,
wantErr: true,
},
{
name: "Invalid log with unclosed quotes",
log: "key1=\"value1 key2=value2",
Expand Down

0 comments on commit 80d502e

Please sign in to comment.