diff --git a/.github/workflows/test-build-deploy.yml b/.github/workflows/test-build-deploy.yml index 0071924e1dd..55062000e05 100644 --- a/.github/workflows/test-build-deploy.yml +++ b/.github/workflows/test-build-deploy.yml @@ -17,7 +17,7 @@ jobs: lint: runs-on: ubuntu-24.04 container: - image: quay.io/cortexproject/build-image:master-03a8f8c98 + image: quay.io/cortexproject/build-image:master-281284ac1 steps: - name: Checkout Repo uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 @@ -46,7 +46,7 @@ jobs: test: runs-on: ubuntu-24.04 container: - image: quay.io/cortexproject/build-image:master-03a8f8c98 + image: quay.io/cortexproject/build-image:master-281284ac1 steps: - name: Checkout Repo uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 @@ -64,7 +64,7 @@ jobs: test-no-race: runs-on: ubuntu-24.04 container: - image: quay.io/cortexproject/build-image:master-03a8f8c98 + image: quay.io/cortexproject/build-image:master-281284ac1 steps: - name: Checkout Repo uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 @@ -107,7 +107,7 @@ jobs: build: runs-on: ubuntu-24.04 container: - image: quay.io/cortexproject/build-image:master-03a8f8c98 + image: quay.io/cortexproject/build-image:master-281284ac1 steps: - name: Checkout Repo uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 @@ -247,14 +247,14 @@ jobs: run: | touch build-image/.uptodate MIGRATIONS_DIR=$(pwd)/cmd/cortex/migrations - make BUILD_IMAGE=quay.io/cortexproject/build-image:master-03a8f8c98 TTY='' configs-integration-test + make BUILD_IMAGE=quay.io/cortexproject/build-image:master-281284ac1 TTY='' configs-integration-test deploy_website: needs: [build, test] if: (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')) && github.repository == 'cortexproject/cortex' runs-on: ubuntu-24.04 container: - image: quay.io/cortexproject/build-image:master-03a8f8c98 + image: quay.io/cortexproject/build-image:master-281284ac1 steps: - name: Checkout Repo uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 @@ -296,7 +296,7 @@ jobs: if: (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')) && github.repository == 'cortexproject/cortex' runs-on: ubuntu-24.04 container: - image: quay.io/cortexproject/build-image:master-03a8f8c98 + image: quay.io/cortexproject/build-image:master-281284ac1 steps: - name: Checkout Repo uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 diff --git a/Makefile b/Makefile index c28676a760d..bfca58e73f1 100644 --- a/Makefile +++ b/Makefile @@ -115,7 +115,7 @@ build-image/$(UPTODATE): build-image/* SUDO := $(shell docker info >/dev/null 2>&1 || echo "sudo -E") BUILD_IN_CONTAINER := true BUILD_IMAGE ?= $(IMAGE_PREFIX)build-image -LATEST_BUILD_IMAGE_TAG ?= master-03a8f8c98 +LATEST_BUILD_IMAGE_TAG ?= master-281284ac1 # TTY is parameterized to allow Google Cloud Builder to run builds, # as it currently disallows TTY devices. This value needs to be overridden diff --git a/go.mod b/go.mod index 856f9a14b0e..f4559c46e21 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/cortexproject/cortex -go 1.23.0 +go 1.24.0 require ( github.com/Masterminds/squirrel v1.5.4 diff --git a/pkg/distributor/distributor.go b/pkg/distributor/distributor.go index 0801bd5138f..f9b347e56e4 100644 --- a/pkg/distributor/distributor.go +++ b/pkg/distributor/distributor.go @@ -730,12 +730,12 @@ func (d *Distributor) Push(ctx context.Context, req *cortexpb.WriteRequest) (*co if errors.Is(err, ha.ReplicasNotMatchError{}) { // These samples have been deduped. d.dedupedSamples.WithLabelValues(userID, cluster).Add(float64(numFloatSamples + numHistogramSamples)) - return nil, httpgrpc.Errorf(http.StatusAccepted, err.Error()) + return nil, httpgrpc.Errorf(http.StatusAccepted, "%s", err.Error()) } if errors.Is(err, ha.TooManyReplicaGroupsError{}) { d.validateMetrics.DiscardedSamples.WithLabelValues(validation.TooManyHAClusters, userID).Add(float64(numFloatSamples + numHistogramSamples)) - return nil, httpgrpc.Errorf(http.StatusBadRequest, err.Error()) + return nil, httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()) } return nil, err @@ -1053,7 +1053,7 @@ func (d *Distributor) prepareSeriesKeys(ctx context.Context, req *cortexpb.Write if validationErr != nil && firstPartialErr == nil { // The series labels may be retained by validationErr but that's not a problem for this // use case because we format it calling Error() and then we discard it. - firstPartialErr = httpgrpc.Errorf(http.StatusBadRequest, validationErr.Error()) + firstPartialErr = httpgrpc.Errorf(http.StatusBadRequest, "%s", validationErr.Error()) } // validateSeries would have returned an emptyPreallocSeries if there were no valid samples. diff --git a/pkg/frontend/transport/handler.go b/pkg/frontend/transport/handler.go index 4580ea1411a..718260beefb 100644 --- a/pkg/frontend/transport/handler.go +++ b/pkg/frontend/transport/handler.go @@ -39,9 +39,9 @@ const ( ) var ( - errCanceled = httpgrpc.Errorf(StatusClientClosedRequest, context.Canceled.Error()) - errDeadlineExceeded = httpgrpc.Errorf(http.StatusGatewayTimeout, context.DeadlineExceeded.Error()) - errRequestEntityTooLarge = httpgrpc.Errorf(http.StatusRequestEntityTooLarge, "http: request body too large") + errCanceled = httpgrpc.Errorf(StatusClientClosedRequest, "%s", context.Canceled.Error()) + errDeadlineExceeded = httpgrpc.Errorf(http.StatusGatewayTimeout, "%s", context.DeadlineExceeded.Error()) + errRequestEntityTooLarge = httpgrpc.Errorf(http.StatusRequestEntityTooLarge, "%s", "http: request body too large") ) const ( @@ -279,7 +279,7 @@ func (f *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { if resp.StatusCode/100 != 2 { body, err2 := tripperware.BodyBuffer(resp, f.log) if err2 == nil { - err = httpgrpc.Errorf(resp.StatusCode, string(body)) + err = httpgrpc.Errorf(resp.StatusCode, "%s", string(body)) } } } diff --git a/pkg/ingester/ingester.go b/pkg/ingester/ingester.go index 63226d6f794..ea8ca3c6f12 100644 --- a/pkg/ingester/ingester.go +++ b/pkg/ingester/ingester.go @@ -1168,7 +1168,7 @@ func (i *Ingester) Push(ctx context.Context, req *cortexpb.WriteRequest) (*corte i.stoppedMtx.RUnlock() if err := db.acquireAppendLock(); err != nil { - return &cortexpb.WriteResponse{}, httpgrpc.Errorf(http.StatusServiceUnavailable, wrapWithUser(err, userID).Error()) + return &cortexpb.WriteResponse{}, httpgrpc.Errorf(http.StatusServiceUnavailable, "%s", wrapWithUser(err, userID).Error()) } defer db.releaseAppendLock() @@ -1506,7 +1506,7 @@ func (i *Ingester) Push(ctx context.Context, req *cortexpb.WriteRequest) (*corte code = ve.code } level.Debug(logutil.WithContext(ctx, i.logger)).Log("msg", "partial failures to push", "totalSamples", succeededSamplesCount+failedSamplesCount, "failedSamples", failedSamplesCount, "totalHistograms", succeededHistogramsCount+failedHistogramsCount, "failedHistograms", failedHistogramsCount, "firstPartialErr", firstPartialErr) - return &cortexpb.WriteResponse{}, httpgrpc.Errorf(code, wrapWithUser(firstPartialErr, userID).Error()) + return &cortexpb.WriteResponse{}, httpgrpc.Errorf(code, "%s", wrapWithUser(firstPartialErr, userID).Error()) } return &cortexpb.WriteResponse{}, nil diff --git a/pkg/ingester/ingester_test.go b/pkg/ingester/ingester_test.go index 943b0bcec79..16dcb0c0c44 100644 --- a/pkg/ingester/ingester_test.go +++ b/pkg/ingester/ingester_test.go @@ -1316,7 +1316,7 @@ func TestIngester_Push(t *testing.T) { }, cortexpb.API), }, - expectedErr: httpgrpc.Errorf(http.StatusBadRequest, wrapWithUser(wrappedTSDBIngestErr(storage.ErrOutOfOrderSample, model.Time(9), cortexpb.FromLabelsToLabelAdapters(metricLabels)), userID).Error()), + expectedErr: httpgrpc.Errorf(http.StatusBadRequest, "%s", wrapWithUser(wrappedTSDBIngestErr(storage.ErrOutOfOrderSample, model.Time(9), cortexpb.FromLabelsToLabelAdapters(metricLabels)), userID).Error()), expectedIngested: []cortexpb.TimeSeries{ {Labels: metricLabelAdapters, Samples: []cortexpb.Sample{{Value: 2, TimestampMs: 10}}}, }, @@ -1384,7 +1384,7 @@ func TestIngester_Push(t *testing.T) { }, cortexpb.API), }, - expectedErr: httpgrpc.Errorf(http.StatusBadRequest, wrapWithUser(wrappedTSDBIngestErr(storage.ErrOutOfBounds, model.Time(1575043969-(86400*1000)), cortexpb.FromLabelsToLabelAdapters(metricLabels)), userID).Error()), + expectedErr: httpgrpc.Errorf(http.StatusBadRequest, "%s", wrapWithUser(wrappedTSDBIngestErr(storage.ErrOutOfBounds, model.Time(1575043969-(86400*1000)), cortexpb.FromLabelsToLabelAdapters(metricLabels)), userID).Error()), expectedIngested: []cortexpb.TimeSeries{ {Labels: metricLabelAdapters, Samples: []cortexpb.Sample{{Value: 2, TimestampMs: 1575043969}}}, }, @@ -1438,7 +1438,7 @@ func TestIngester_Push(t *testing.T) { cortexpb.API), }, oooTimeWindow: 5 * time.Minute, - expectedErr: httpgrpc.Errorf(http.StatusBadRequest, wrapWithUser(wrappedTSDBIngestErr(storage.ErrTooOldSample, model.Time(1575043969-(600*1000)), cortexpb.FromLabelsToLabelAdapters(metricLabels)), userID).Error()), + expectedErr: httpgrpc.Errorf(http.StatusBadRequest, "%s", wrapWithUser(wrappedTSDBIngestErr(storage.ErrTooOldSample, model.Time(1575043969-(600*1000)), cortexpb.FromLabelsToLabelAdapters(metricLabels)), userID).Error()), expectedIngested: []cortexpb.TimeSeries{ {Labels: metricLabelAdapters, Samples: []cortexpb.Sample{{Value: 2, TimestampMs: 1575043969}}}, }, @@ -1534,7 +1534,7 @@ func TestIngester_Push(t *testing.T) { }, oooTimeWindow: 5 * time.Minute, enableOOONativeHistograms: false, - expectedErr: httpgrpc.Errorf(http.StatusBadRequest, wrapWithUser(wrappedTSDBIngestErr(storage.ErrOOONativeHistogramsDisabled, model.Time(1575043969-(10)), cortexpb.FromLabelsToLabelAdapters(metricLabels)), userID).Error()), + expectedErr: httpgrpc.Errorf(http.StatusBadRequest, "%s", wrapWithUser(wrappedTSDBIngestErr(storage.ErrOOONativeHistogramsDisabled, model.Time(1575043969-(10)), cortexpb.FromLabelsToLabelAdapters(metricLabels)), userID).Error()), expectedIngested: []cortexpb.TimeSeries{ {Labels: metricLabelAdapters, Histograms: []cortexpb.Histogram{cortexpb.HistogramToHistogramProto(1575043969, tsdbutil.GenerateTestHistogram(1))}}, }, @@ -1593,7 +1593,7 @@ func TestIngester_Push(t *testing.T) { }, oooTimeWindow: 5 * time.Minute, enableOOONativeHistograms: true, - expectedErr: httpgrpc.Errorf(http.StatusBadRequest, wrapWithUser(wrappedTSDBIngestErr(storage.ErrTooOldSample, model.Time(1575043969-(600*1000)), cortexpb.FromLabelsToLabelAdapters(metricLabels)), userID).Error()), + expectedErr: httpgrpc.Errorf(http.StatusBadRequest, "%s", wrapWithUser(wrappedTSDBIngestErr(storage.ErrTooOldSample, model.Time(1575043969-(600*1000)), cortexpb.FromLabelsToLabelAdapters(metricLabels)), userID).Error()), expectedIngested: []cortexpb.TimeSeries{ {Labels: metricLabelAdapters, Histograms: []cortexpb.Histogram{cortexpb.HistogramToHistogramProto(1575043969, tsdbutil.GenerateTestHistogram(1))}}, }, @@ -1712,7 +1712,7 @@ func TestIngester_Push(t *testing.T) { nil, cortexpb.API), }, - expectedErr: httpgrpc.Errorf(http.StatusBadRequest, wrapWithUser(wrappedTSDBIngestErr(storage.NewDuplicateFloatErr(1575043969, 2, 1), model.Time(1575043969), cortexpb.FromLabelsToLabelAdapters(metricLabels)), userID).Error()), + expectedErr: httpgrpc.Errorf(http.StatusBadRequest, "%s", wrapWithUser(wrappedTSDBIngestErr(storage.NewDuplicateFloatErr(1575043969, 2, 1), model.Time(1575043969), cortexpb.FromLabelsToLabelAdapters(metricLabels)), userID).Error()), expectedIngested: []cortexpb.TimeSeries{ {Labels: metricLabelAdapters, Samples: []cortexpb.Sample{{Value: 2, TimestampMs: 1575043969}}}, }, @@ -1766,7 +1766,7 @@ func TestIngester_Push(t *testing.T) { }, }, }, - expectedErr: httpgrpc.Errorf(http.StatusBadRequest, wrapWithUser(wrappedTSDBIngestExemplarErr(errExemplarRef, model.Time(1000), cortexpb.FromLabelsToLabelAdapters(metricLabels), []cortexpb.LabelAdapter{{Name: "traceID", Value: "123"}}), userID).Error()), + expectedErr: httpgrpc.Errorf(http.StatusBadRequest, "%s", wrapWithUser(wrappedTSDBIngestExemplarErr(errExemplarRef, model.Time(1000), cortexpb.FromLabelsToLabelAdapters(metricLabels), []cortexpb.LabelAdapter{{Name: "traceID", Value: "123"}}), userID).Error()), expectedIngested: nil, expectedMetadataIngested: nil, additionalMetrics: []string{ @@ -2260,7 +2260,7 @@ func TestIngester_PushNativeHistogramErrors(t *testing.T) { req := cortexpb.ToWriteRequest([]labels.Labels{metricLabels}, nil, nil, tc.histograms, cortexpb.API) // Push timeseries _, err = i.Push(ctx, req) - assert.Equal(t, httpgrpc.Errorf(http.StatusBadRequest, wrapWithUser(wrappedTSDBIngestErr(tc.expectedErr, model.Time(10), metricLabelAdapters), userID).Error()), err) + assert.Equal(t, httpgrpc.Errorf(http.StatusBadRequest, "%s", wrapWithUser(wrappedTSDBIngestErr(tc.expectedErr, model.Time(10), metricLabelAdapters), userID).Error()), err) require.Equal(t, testutil.ToFloat64(i.metrics.ingestedHistogramsFail), float64(1)) }) @@ -5557,7 +5557,7 @@ func TestIngesterPushErrorDuringForcedCompaction(t *testing.T) { req, _ := mockWriteRequest(t, labels.Labels{{Name: labels.MetricName, Value: "test"}}, 0, util.TimeToMillis(time.Now())) ctx := user.InjectOrgID(context.Background(), userID) _, err = i.Push(ctx, req) - require.Equal(t, httpgrpc.Errorf(http.StatusServiceUnavailable, wrapWithUser(errors.New("forced compaction in progress"), userID).Error()), err) + require.Equal(t, httpgrpc.Errorf(http.StatusServiceUnavailable, "%s", wrapWithUser(errors.New("forced compaction in progress"), userID).Error()), err) // Ingestion is successful after a flush. require.True(t, db.casState(forceCompacting, active)) diff --git a/pkg/querier/tripperware/instantquery/instant_query.go b/pkg/querier/tripperware/instantquery/instant_query.go index 54016c7746e..930b3fde691 100644 --- a/pkg/querier/tripperware/instantquery/instant_query.go +++ b/pkg/querier/tripperware/instantquery/instant_query.go @@ -106,7 +106,7 @@ func (instantQueryCodec) DecodeResponse(ctx context.Context, r *http.Response, _ return nil, err } if r.StatusCode/100 != 2 { - return nil, httpgrpc.Errorf(r.StatusCode, string(buf)) + return nil, httpgrpc.Errorf(r.StatusCode, "%s", string(buf)) } var resp tripperware.PrometheusResponse diff --git a/pkg/querier/tripperware/instantquery/limits.go b/pkg/querier/tripperware/instantquery/limits.go index d782866148d..5c9514b957b 100644 --- a/pkg/querier/tripperware/instantquery/limits.go +++ b/pkg/querier/tripperware/instantquery/limits.go @@ -40,14 +40,14 @@ func (l limitsMiddleware) Do(ctx context.Context, r tripperware.Request) (trippe tenantIDs, err := tenant.TenantIDs(ctx) if err != nil { - return nil, httpgrpc.Errorf(http.StatusBadRequest, err.Error()) + return nil, httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()) } // Enforce the max query length. if maxQueryLength := validation.SmallestPositiveNonZeroDurationPerTenant(tenantIDs, l.MaxQueryLength); maxQueryLength > 0 { expr, err := parser.ParseExpr(r.GetQuery()) if err != nil { - return nil, httpgrpc.Errorf(http.StatusBadRequest, err.Error()) + return nil, httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()) } // Enforce query length across all selectors in the query. diff --git a/pkg/querier/tripperware/instantquery/limits_test.go b/pkg/querier/tripperware/instantquery/limits_test.go index e209d366f38..74f5c7c4d86 100644 --- a/pkg/querier/tripperware/instantquery/limits_test.go +++ b/pkg/querier/tripperware/instantquery/limits_test.go @@ -37,7 +37,7 @@ func TestLimitsMiddleware_MaxQueryLength(t *testing.T) { "even though failed to parse expression, should return no error since request will pass to next middleware": { query: `up[`, maxQueryLength: thirtyDays, - expectedErr: httpgrpc.Errorf(http.StatusBadRequest, parserErr.Error()).Error(), + expectedErr: httpgrpc.Errorf(http.StatusBadRequest, "%s", parserErr.Error()).Error(), }, "should succeed on a query not exceeding time range": { query: `up`, diff --git a/pkg/querier/tripperware/query_attribute_matcher.go b/pkg/querier/tripperware/query_attribute_matcher.go index 169a50553fc..10c0319ab85 100644 --- a/pkg/querier/tripperware/query_attribute_matcher.go +++ b/pkg/querier/tripperware/query_attribute_matcher.go @@ -26,7 +26,7 @@ func rejectQueryOrSetPriority(r *http.Request, now time.Time, lookbackDelta time query := r.FormValue("query") expr, err := parser.ParseExpr(query) if err != nil { - return httpgrpc.Errorf(http.StatusBadRequest, err.Error()) + return httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()) } minTime, maxTime := util.FindMinMaxTime(r, expr, lookbackDelta, now) diff --git a/pkg/querier/tripperware/queryrange/limits.go b/pkg/querier/tripperware/queryrange/limits.go index 4aa93185957..817fcf50834 100644 --- a/pkg/querier/tripperware/queryrange/limits.go +++ b/pkg/querier/tripperware/queryrange/limits.go @@ -43,7 +43,7 @@ func (l limitsMiddleware) Do(ctx context.Context, r tripperware.Request) (trippe tenantIDs, err := tenant.TenantIDs(ctx) if err != nil { - return nil, httpgrpc.Errorf(http.StatusBadRequest, err.Error()) + return nil, httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()) } // Clamp the time range based on the max query lookback. @@ -84,7 +84,7 @@ func (l limitsMiddleware) Do(ctx context.Context, r tripperware.Request) (trippe expr, err := parser.ParseExpr(r.GetQuery()) if err != nil { - return nil, httpgrpc.Errorf(http.StatusBadRequest, err.Error()) + return nil, httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()) } // Enforce query length across all selectors in the query. diff --git a/pkg/querier/tripperware/queryrange/limits_test.go b/pkg/querier/tripperware/queryrange/limits_test.go index 09cfe77b98a..0631ff23439 100644 --- a/pkg/querier/tripperware/queryrange/limits_test.go +++ b/pkg/querier/tripperware/queryrange/limits_test.go @@ -138,7 +138,7 @@ func TestLimitsMiddleware_MaxQueryLength(t *testing.T) { reqStartTime: now.Add(-time.Hour), reqEndTime: now, maxQueryLength: thirtyDays, - expectedErr: httpgrpc.Errorf(http.StatusBadRequest, parserErr.Error()).Error(), + expectedErr: httpgrpc.Errorf(http.StatusBadRequest, "%s", parserErr.Error()).Error(), }, "should succeed on a query on short time range, ending now": { maxQueryLength: thirtyDays, diff --git a/pkg/querier/tripperware/queryrange/query_range.go b/pkg/querier/tripperware/queryrange/query_range.go index 1693408ea91..98c63790d2b 100644 --- a/pkg/querier/tripperware/queryrange/query_range.go +++ b/pkg/querier/tripperware/queryrange/query_range.go @@ -34,9 +34,9 @@ var ( SortMapKeys: true, ValidateJsonRawMessage: false, }.Froze() - errEndBeforeStart = httpgrpc.Errorf(http.StatusBadRequest, "end timestamp must not be before start time") - errNegativeStep = httpgrpc.Errorf(http.StatusBadRequest, "zero or negative query resolution step widths are not accepted. Try a positive integer") - errStepTooSmall = httpgrpc.Errorf(http.StatusBadRequest, "exceeded maximum resolution of 11,000 points per timeseries. Try decreasing the query resolution (?step=XX)") + errEndBeforeStart = httpgrpc.Errorf(http.StatusBadRequest, "%s", "end timestamp must not be before start time") + errNegativeStep = httpgrpc.Errorf(http.StatusBadRequest, "%s", "zero or negative query resolution step widths are not accepted. Try a positive integer") + errStepTooSmall = httpgrpc.Errorf(http.StatusBadRequest, "%s", "exceeded maximum resolution of 11,000 points per timeseries. Try decreasing the query resolution (?step=XX)") // Name of the cache control header. cacheControlHeader = "Cache-Control" @@ -204,7 +204,7 @@ func (c prometheusCodec) DecodeResponse(ctx context.Context, r *http.Response, _ return nil, err } if r.StatusCode/100 != 2 { - return nil, httpgrpc.Errorf(r.StatusCode, string(buf)) + return nil, httpgrpc.Errorf(r.StatusCode, "%s", string(buf)) } log.LogFields(otlog.Int("bytes", len(buf))) diff --git a/pkg/querier/tripperware/queryrange/results_cache.go b/pkg/querier/tripperware/queryrange/results_cache.go index 1f7ab241137..3f581586ce2 100644 --- a/pkg/querier/tripperware/queryrange/results_cache.go +++ b/pkg/querier/tripperware/queryrange/results_cache.go @@ -224,7 +224,7 @@ func (s resultsCache) Do(ctx context.Context, r tripperware.Request) (tripperwar tenantIDs, err := tenant.TenantIDs(ctx) respWithStats := r.GetStats() != "" && s.cacheQueryableSamplesStats if err != nil { - return nil, httpgrpc.Errorf(http.StatusBadRequest, err.Error()) + return nil, httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()) } // If cache_queryable_samples_stats is enabled we always need request the status upstream @@ -241,7 +241,7 @@ func (s resultsCache) Do(ctx context.Context, r tripperware.Request) (tripperwar key := s.splitter.GenerateCacheKey(ctx, tenant.JoinTenantIDs(tenantIDs), r) if err != nil { - return nil, httpgrpc.Errorf(http.StatusBadRequest, err.Error()) + return nil, httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()) } var ( diff --git a/pkg/querier/tripperware/queryrange/split_by_interval.go b/pkg/querier/tripperware/queryrange/split_by_interval.go index c7b2897c7c3..138338daf82 100644 --- a/pkg/querier/tripperware/queryrange/split_by_interval.go +++ b/pkg/querier/tripperware/queryrange/split_by_interval.go @@ -54,11 +54,11 @@ func (s splitByInterval) Do(ctx context.Context, r tripperware.Request) (tripper // to line up the boundaries with step. interval, err := s.interval(ctx, r) if err != nil { - return nil, httpgrpc.Errorf(http.StatusBadRequest, err.Error()) + return nil, httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()) } reqs, err := splitQuery(r, interval) if err != nil { - return nil, httpgrpc.Errorf(http.StatusBadRequest, err.Error()) + return nil, httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()) } s.splitByCounter.Add(float64(len(reqs))) diff --git a/pkg/querier/tripperware/roundtrip.go b/pkg/querier/tripperware/roundtrip.go index e0b5168bad0..91da895dc4a 100644 --- a/pkg/querier/tripperware/roundtrip.go +++ b/pkg/querier/tripperware/roundtrip.go @@ -179,7 +179,7 @@ func NewQueryTripperware( tenantIDs, err := tenant.TenantIDs(r.Context()) // This should never happen anyways because we have auth middleware before this. if err != nil { - return nil, httpgrpc.Errorf(http.StatusBadRequest, err.Error()) + return nil, httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()) } now := time.Now() userStr := tenant.JoinTenantIDs(tenantIDs) @@ -255,7 +255,7 @@ func (q roundTripper) Do(ctx context.Context, r Request) (Response, error) { } if err := user.InjectOrgIDIntoHTTPRequest(ctx, request); err != nil { - return nil, httpgrpc.Errorf(http.StatusBadRequest, err.Error()) + return nil, httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()) } response, err := q.next.RoundTrip(request) diff --git a/pkg/querier/tripperware/shard_by.go b/pkg/querier/tripperware/shard_by.go index 7336bd21ede..fe6293832f1 100644 --- a/pkg/querier/tripperware/shard_by.go +++ b/pkg/querier/tripperware/shard_by.go @@ -42,7 +42,7 @@ func (s shardBy) Do(ctx context.Context, r Request) (Response, error) { stats := querier_stats.FromContext(ctx) if err != nil { - return nil, httpgrpc.Errorf(http.StatusBadRequest, err.Error()) + return nil, httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()) } numShards := validation.SmallestPositiveIntPerTenant(tenantIDs, s.limits.QueryVerticalShardSize) @@ -55,7 +55,7 @@ func (s shardBy) Do(ctx context.Context, r Request) (Response, error) { analysis, err := s.analyzer.Analyze(r.GetQuery()) if err != nil { level.Warn(logger).Log("msg", "error analyzing query", "q", r.GetQuery(), "err", err) - return nil, httpgrpc.Errorf(http.StatusBadRequest, err.Error()) + return nil, httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()) } stats.AddExtraFields( diff --git a/pkg/querier/tripperware/util.go b/pkg/querier/tripperware/util.go index d9b3551ce29..c1e2144b969 100644 --- a/pkg/querier/tripperware/util.go +++ b/pkg/querier/tripperware/util.go @@ -21,7 +21,7 @@ type RequestResponse struct { func DoRequests(ctx context.Context, downstream Handler, reqs []Request, limits Limits) ([]RequestResponse, error) { tenantIDs, err := tenant.TenantIDs(ctx) if err != nil { - return nil, httpgrpc.Errorf(http.StatusBadRequest, err.Error()) + return nil, httpgrpc.Errorf(http.StatusBadRequest, "%s", err.Error()) } // If one of the requests fail, we want to be able to cancel the rest of them. diff --git a/pkg/storegateway/limiter.go b/pkg/storegateway/limiter.go index 7a633e24223..d907925505b 100644 --- a/pkg/storegateway/limiter.go +++ b/pkg/storegateway/limiter.go @@ -28,7 +28,7 @@ func (c *limiter) Reserve(num uint64) error { func (c *limiter) ReserveWithType(num uint64, _ store.StoreDataType) error { err := c.limiter.Reserve(num) if err != nil { - return httpgrpc.Errorf(http.StatusUnprocessableEntity, err.Error()) + return httpgrpc.Errorf(http.StatusUnprocessableEntity, "%s", err.Error()) } return nil