diff --git a/src/query/storage/m3/cluster_resolver.go b/src/query/storage/m3/cluster_resolver.go index 09eecac9aa..b1260959a8 100644 --- a/src/query/storage/m3/cluster_resolver.go +++ b/src/query/storage/m3/cluster_resolver.go @@ -28,6 +28,7 @@ import ( "github.com/m3db/m3/src/query/storage" "github.com/m3db/m3/src/query/storage/m3/consolidators" "github.com/m3db/m3/src/query/storage/m3/storagemetadata" + xerrors "github.com/m3db/m3/src/x/errors" ) type unaggregatedNamespaceType uint8 @@ -346,15 +347,17 @@ func resolveClusterNamespacesForQueryWithRestrictQueryOptions( Resolution: restrict.StoragePolicy.Resolution().Window, }) if !ok { - return result(nil, + err := xerrors.NewInvalidParamsError( fmt.Errorf("could not find namespace for storage policy: %v", restrict.StoragePolicy.String())) + return result(nil, err) } return result(ns, nil) default: - return result(nil, + err := xerrors.NewInvalidParamsError( fmt.Errorf("unrecognized metrics type: %v", restrict.MetricsType)) + return result(nil, err) } } diff --git a/src/query/storage/m3/cluster_resolver_test.go b/src/query/storage/m3/cluster_resolver_test.go index 5db69c7f26..2e1d7099ce 100644 --- a/src/query/storage/m3/cluster_resolver_test.go +++ b/src/query/storage/m3/cluster_resolver_test.go @@ -31,6 +31,7 @@ import ( "github.com/m3db/m3/src/query/storage" "github.com/m3db/m3/src/query/storage/m3/consolidators" "github.com/m3db/m3/src/query/storage/m3/storagemetadata" + xerrors "github.com/m3db/m3/src/x/errors" "github.com/m3db/m3/src/x/ident" "github.com/golang/mock/gomock" @@ -162,14 +163,15 @@ func generateClusters(t *testing.T, ctrl *gomock.Controller) Clusters { } var testCases = []struct { - name string - queryLength time.Duration - opts *storage.FanoutOptions - restrict *storage.RestrictQueryOptions - expectedType consolidators.QueryFanoutType - expectedClusterNames []string - expectedErr error - expectedErrContains string + name string + queryLength time.Duration + opts *storage.FanoutOptions + restrict *storage.RestrictQueryOptions + expectedType consolidators.QueryFanoutType + expectedClusterNames []string + expectedErr error + expectedErrContains string + expectedErrInvalidParams bool }{ { name: "all disabled", @@ -355,7 +357,8 @@ var testCases = []struct { MetricsType: storagemetadata.UnknownMetricsType, }, }, - expectedErrContains: "unrecognized metrics type:", + expectedErrContains: "unrecognized metrics type:", + expectedErrInvalidParams: true, }, { name: "restrict with unknown storage policy", @@ -366,7 +369,8 @@ var testCases = []struct { StoragePolicy: policy.MustParseStoragePolicy("1s:100d"), }, }, - expectedErrContains: "could not find namespace for storage policy:", + expectedErrContains: "could not find namespace for storage policy:", + expectedErrInvalidParams: true, }, } @@ -398,6 +402,8 @@ func TestResolveClusterNamespacesForQueryWithOptions(t *testing.T) { assert.Error(t, err) assert.True(t, strings.Contains(err.Error(), substr)) assert.Nil(t, clusters) + invalidParams := xerrors.IsInvalidParams(err) + assert.Equal(t, tt.expectedErrInvalidParams, invalidParams) return }