Skip to content

Commit

Permalink
Apply CR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
salvacorts committed Jun 29, 2023
1 parent f43dfab commit 384d556
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions pkg/loghttp/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ func (s *LogProtoStream) UnmarshalJSON(data []byte) error {
switch string(key) {
case "stream":
labels := make(LabelSet)
err := jsonparser.ObjectEach(val, func(key, val []byte, _ jsonparser.ValueType, _ int) error {
err := jsonparser.ObjectEach(val, func(key, val []byte, dataType jsonparser.ValueType, _ int) error {
if dataType != jsonparser.String {
return jsonparser.MalformedStringError
}
labels[yoloString(key)] = yoloString(val)
return nil
})
Expand Down Expand Up @@ -99,7 +102,7 @@ func unmarshalHTTPToLogProtoEntries(data []byte) ([]logproto.Entry, error) {
entries []logproto.Entry
parseError error
)
_, err := jsonparser.ArrayEach(data, func(value []byte, ty jsonparser.ValueType, _ int, err error) {
if _, err := jsonparser.ArrayEach(data, func(value []byte, ty jsonparser.ValueType, _ int, err error) {
if err != nil || parseError != nil {
return
}
Expand All @@ -112,11 +115,11 @@ func unmarshalHTTPToLogProtoEntries(data []byte) ([]logproto.Entry, error) {
return
}
entries = append(entries, e)
})
if parseError != nil {
return nil, parseError
}); err != nil {
parseError = err
}
if err != nil {

if parseError != nil {
return nil, parseError
}

Expand Down Expand Up @@ -155,7 +158,10 @@ func unmarshalHTTPToLogProtoEntry(data []byte) (logproto.Entry, error) {
e.Line = v
case 2: // labels
labels := make(LabelSet)
err := jsonparser.ObjectEach(value, func(key, val []byte, _ jsonparser.ValueType, _ int) error {
err := jsonparser.ObjectEach(value, func(key, val []byte, dataType jsonparser.ValueType, _ int) error {
if dataType != jsonparser.String {
return jsonparser.MalformedStringError
}
labels[yoloString(key)] = yoloString(val)
return nil
})
Expand Down

0 comments on commit 384d556

Please sign in to comment.