Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Unknown value type error for array string value #10690

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -351,3 +351,6 @@ replace github.com/grafana/loki/pkg/push => ./pkg/push

// Pin grpc to previous version: using newer version breaks kuberesolver, but updating kuberesolver needs to be done in weaveworks/common.
replace google.golang.org/grpc => google.golang.org/grpc v1.53.0

// Leave this until https://github.com/buger/jsonparser/pull/180 is merged
replace github.com/buger/jsonparser => github.com/floren/jsonparser v0.0.0-20221212180010-bf73ef709df6
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -613,8 +613,6 @@ github.com/bmatcuk/doublestar v1.3.4/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY=
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps=
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
github.com/c2h5oh/datasize v0.0.0-20200112174442-28bbd4740fee h1:BnPxIde0gjtTnc9Er7cxvBk8DHLWhEux0SxayC8dP6I=
github.com/c2h5oh/datasize v0.0.0-20200112174442-28bbd4740fee/go.mod h1:S/7n9copUssQ56c7aAgHqftWO4LTf4xY6CGWt8Bc+3M=
github.com/caio/go-tdigest v2.3.0+incompatible/go.mod h1:sHQM/ubZStBUmF1WbB8FAm8q9GjDajLC5T7ydxE3JHI=
Expand Down Expand Up @@ -777,6 +775,8 @@ github.com/felixge/fgprof v0.9.3 h1:VvyZxILNuCiUCSXtPtYmmtGvb65nqXh2QFWc0Wpf2/g=
github.com/felixge/fgprof v0.9.3/go.mod h1:RdbpDgzqYVh/T9fPELJyV7EYJuHB55UTEULNun8eiPw=
github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk=
github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/floren/jsonparser v0.0.0-20221212180010-bf73ef709df6 h1:kDHOghcSsQENgHxvQM/OmWndRPpxdv/uVwKzvGOXHbg=
github.com/floren/jsonparser v0.0.0-20221212180010-bf73ef709df6/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
github.com/flowstack/go-jsonschema v0.1.1/go.mod h1:yL7fNggx1o8rm9RlgXv7hTBWxdBM0rVwpMwimd3F3N0=
github.com/fluent/fluent-bit-go v0.0.0-20190925192703-ea13c021720c h1:QwbffUs/+ptC4kTFPEN9Ej2latTq3bZJ5HO/OwPXYMs=
github.com/fluent/fluent-bit-go v0.0.0-20190925192703-ea13c021720c/go.mod h1:WQX+afhrekY9rGK+WT4xvKSlzmia9gDoLYu4GGYGASQ=
Expand Down
16 changes: 13 additions & 3 deletions pkg/logql/log/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func (p *fakeParseHints) ShouldContinueParsingLine(_ string, _ *LabelsBuilder) b
}

func TestJSONExpressionParser(t *testing.T) {
testLine := []byte(`{"app":"foo","field with space":"value","field with ÜFT8👌":"value","null_field":null,"bool_field":false,"namespace":"prod","pod":{"uuid":"foo","deployment":{"ref":"foobar", "params": [1,2,3]}}}`)
testLine := []byte(`{"app":"foo","field with space":"value","field with ÜFT8👌":"value","null_field":null,"bool_field":false,"namespace":"prod","pod":{"uuid":"foo","deployment":{"ref":"foobar", "params": [1,2,3,"string_value"]}}}`)

tests := []struct {
name string
Expand Down Expand Up @@ -339,14 +339,24 @@ func TestJSONExpressionParser(t *testing.T) {
labels.FromStrings("param", "1"),
noParserHints,
},
{
"array string element",
testLine,
[]LabelExtractionExpr{
NewLabelExtractionExpr("param", `pod.deployment.params[3]`),
},
labels.EmptyLabels(),
labels.FromStrings("param", "string_value"),
noParserHints,
},
{
"full array",
testLine,
[]LabelExtractionExpr{
NewLabelExtractionExpr("params", `pod.deployment.params`),
},
labels.EmptyLabels(),
labels.FromStrings("params", "[1,2,3]"),
labels.FromStrings("params", `[1,2,3,"string_value"]`),
noParserHints,
},
{
Expand All @@ -356,7 +366,7 @@ func TestJSONExpressionParser(t *testing.T) {
NewLabelExtractionExpr("deployment", `pod.deployment`),
},
labels.EmptyLabels(),
labels.FromStrings("deployment", `{"ref":"foobar", "params": [1,2,3]}`),
labels.FromStrings("deployment", `{"ref":"foobar", "params": [1,2,3,"string_value"]}`),
noParserHints,
},
{
Expand Down
11 changes: 6 additions & 5 deletions vendor/github.com/buger/jsonparser/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions vendor/github.com/buger/jsonparser/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 18 additions & 18 deletions vendor/github.com/buger/jsonparser/bytes.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 47 additions & 11 deletions vendor/github.com/buger/jsonparser/parser.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ github.com/beorn7/perks/quantile
# github.com/bmatcuk/doublestar v1.3.4
## explicit; go 1.12
github.com/bmatcuk/doublestar
# github.com/buger/jsonparser v1.1.1
# github.com/buger/jsonparser v1.1.1 => github.com/floren/jsonparser v0.0.0-20221212180010-bf73ef709df6
## explicit; go 1.13
github.com/buger/jsonparser
# github.com/c2h5oh/datasize v0.0.0-20200112174442-28bbd4740fee
Expand Down Expand Up @@ -2171,3 +2171,4 @@ sigs.k8s.io/yaml
# github.com/grafana/regexp => github.com/grafana/regexp v0.0.0-20221005093135-b4c2bcb0a4b6
# github.com/grafana/loki/pkg/push => ./pkg/push
# google.golang.org/grpc => google.golang.org/grpc v1.53.0
# github.com/buger/jsonparser => github.com/floren/jsonparser v0.0.0-20221212180010-bf73ef709df6
Loading