Skip to content

Commit

Permalink
Fix downstream errors for ErrExpressionNotFoundInFields and ErrInvali…
Browse files Browse the repository at this point in the history
…dFilterExpression (#1014)
  • Loading branch information
ivanahuckova authored Oct 9, 2024
1 parent 50aead8 commit 9d6bf2c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ require (
github.com/grafana/grafana-aws-sdk v0.24.0
github.com/grafana/grafana-plugin-sdk-go v0.248.0
github.com/grafana/infinity-libs/lib/go/csvframer v1.0.1
github.com/grafana/infinity-libs/lib/go/framesql v1.0.1
github.com/grafana/infinity-libs/lib/go/framesql v1.0.2
github.com/grafana/infinity-libs/lib/go/gframer v1.0.0
github.com/grafana/infinity-libs/lib/go/jsonframer v1.1.4
github.com/grafana/infinity-libs/lib/go/macros v1.0.0
github.com/grafana/infinity-libs/lib/go/transformations v1.0.1
github.com/grafana/infinity-libs/lib/go/transformations v1.0.3
github.com/grafana/infinity-libs/lib/go/xmlframer v1.0.0
github.com/icholy/digest v0.1.22
github.com/stretchr/testify v1.9.0
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,16 @@ github.com/grafana/grafana-plugin-sdk-go v0.248.0 h1:wXseE6exRWfjUlqDr/ArocK1EPm
github.com/grafana/grafana-plugin-sdk-go v0.248.0/go.mod h1:sEi0wRVTvpxyB0KaMNbhPM74OnDMwVpah97usm6QXEM=
github.com/grafana/infinity-libs/lib/go/csvframer v1.0.1 h1:SBL+Ix6E1Ec6QPdAkq/yhyqvicV5wyWlHKB0bH8jjIA=
github.com/grafana/infinity-libs/lib/go/csvframer v1.0.1/go.mod h1:gVqJA9np8h1RpZYemoVouIe/b3m2lUc5HVAbdM7K8sM=
github.com/grafana/infinity-libs/lib/go/framesql v1.0.1 h1:q8hqwHIcfWRxUq6YWGGXnim79WXHAjZOqUqRPGykJNU=
github.com/grafana/infinity-libs/lib/go/framesql v1.0.1/go.mod h1:Z1LC4OCGQ/Bc4w+bDt63vUWkLml5Q3m/Pim/TXFGHfg=
github.com/grafana/infinity-libs/lib/go/framesql v1.0.2 h1:fWTC2tG9nKx8xp9V/IXfeEC7auMEBTE/FxysEeKC1fg=
github.com/grafana/infinity-libs/lib/go/framesql v1.0.2/go.mod h1:Z1LC4OCGQ/Bc4w+bDt63vUWkLml5Q3m/Pim/TXFGHfg=
github.com/grafana/infinity-libs/lib/go/gframer v1.0.0 h1:TYKumCoWlf9KlXa6M9pi3s6H9bjl0V5XF8f73aitNWE=
github.com/grafana/infinity-libs/lib/go/gframer v1.0.0/go.mod h1:tCjLSNFQnuYiNeBIAyb51jNV8ad0eI/M69P1rxm77Fc=
github.com/grafana/infinity-libs/lib/go/jsonframer v1.1.4 h1:boSnUP+ZuFJByvfFozX7www10ApnAKPmsUfXcxl0YLI=
github.com/grafana/infinity-libs/lib/go/jsonframer v1.1.4/go.mod h1:HLkUysTFcEDE6E/j2OHcd2TcpROSlqX1N3l4DkVTzdE=
github.com/grafana/infinity-libs/lib/go/macros v1.0.0 h1:5IaWKGvY0zhli0MKfjKvS1Y+bzY758Yw8HELU4cqs6E=
github.com/grafana/infinity-libs/lib/go/macros v1.0.0/go.mod h1:6EE8D9bV9J9nC9gQSD1HirqCKHhWKaEaZYJsajM6PGk=
github.com/grafana/infinity-libs/lib/go/transformations v1.0.1 h1:PlV0NiWn9Lmfrodkjn91s/IRoIY4pL9jnuvtX4Hd3ZE=
github.com/grafana/infinity-libs/lib/go/transformations v1.0.1/go.mod h1:/WACyqQiCKo7lTezxRyMYaGYM/lVF8/u9b56z1amb40=
github.com/grafana/infinity-libs/lib/go/transformations v1.0.3 h1:1ruYu3D9IsfNF7o8jU4zIowbq99YnX77Lt/hmvIj3pg=
github.com/grafana/infinity-libs/lib/go/transformations v1.0.3/go.mod h1:/WACyqQiCKo7lTezxRyMYaGYM/lVF8/u9b56z1amb40=
github.com/grafana/infinity-libs/lib/go/utils v1.0.0 h1:jXlKDSay/S2tdaWghc0E7DzKugMQhEUcKtlVPmb69oc=
github.com/grafana/infinity-libs/lib/go/utils v1.0.0/go.mod h1:86US+G1Ujk61fibdPSEHWl+atBjXGGeibuEOMfMU2v4=
github.com/grafana/infinity-libs/lib/go/xmlframer v1.0.0 h1:I8aMygkFiaBQUktugOIOjaigO0p/DgS94/ikr5G+WRw=
Expand Down
11 changes: 11 additions & 0 deletions pkg/infinity/posprocess_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"testing"

"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/infinity-libs/lib/go/framesql"
"github.com/grafana/infinity-libs/lib/go/transformations"
"github.com/stretchr/testify/require"
)
Expand All @@ -32,6 +33,16 @@ tests := []struct {
inputError: errors.Join(transformations.ErrNotUniqueFieldNames, fmt.Errorf("some random error")),
isDownstream: true,
},
{
name: "Downstream error joined - ErrExpressionNotFoundInFields",
inputError: errors.Join(framesql.ErrExpressionNotFoundInFields, fmt.Errorf("some random error")),
isDownstream: true,
},
{
name: "Downstream error joined - ErrInvalidFilterExpression",
inputError: errors.Join(transformations.ErrInvalidFilterExpression, fmt.Errorf("some random error")),
isDownstream: true,
},
{
name: "Non-Downstream error",
inputError: errors.New("some random error"),
Expand Down
7 changes: 5 additions & 2 deletions pkg/infinity/postprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ func PostProcessFrame(ctx context.Context, frame *data.Frame, query models.Query
if err != nil {
logger.Error("error applying filter", "error", err.Error())
frame.Meta.Custom = &CustomMeta{Query: query, Error: err.Error()}
return frame, errorsource.PluginError(fmt.Errorf("error applying filter. %w", err), false)
err = addErrorSourceToTransformError(fmt.Errorf("error applying filter. %w", err))
return frame, err
}
if strings.TrimSpace(query.SummarizeExpression) != "" {
alias := query.SummarizeAlias
Expand Down Expand Up @@ -69,8 +70,10 @@ func addErrorSourceToTransformError(err error) error {
t.ErrMergeTransformationNoFrameSupplied,
t.ErrMergeTransformationDifferentFields,
t.ErrMergeTransformationDifferentFieldNames,
t.ErrMergeTransformationDifferentFieldTypes,
t.ErrMergeTransformationDifferentFieldTypes,
t.ErrInvalidFilterExpression,
framesql.ErrEmptySummarizeExpression,
framesql.ErrExpressionNotFoundInFields,
}

for _, e := range downstreamErrors {
Expand Down

0 comments on commit 9d6bf2c

Please sign in to comment.