From 2c14d78f3d50cc656e89867d7abf399d1661d1d4 Mon Sep 17 00:00:00 2001 From: tdakkota Date: Fri, 12 Apr 2024 13:12:53 +0300 Subject: [PATCH] fix(lokihandler): properly handle unsupported error --- internal/lokihandler/lokihandler.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/lokihandler/lokihandler.go b/internal/lokihandler/lokihandler.go index 297cd22f..361e969a 100644 --- a/internal/lokihandler/lokihandler.go +++ b/internal/lokihandler/lokihandler.go @@ -14,6 +14,7 @@ import ( "github.com/go-faster/oteldb/internal/iterators" "github.com/go-faster/oteldb/internal/logql/logqlengine" + "github.com/go-faster/oteldb/internal/logql/logqlengine/logqlerrors" "github.com/go-faster/oteldb/internal/logstorage" "github.com/go-faster/oteldb/internal/lokiapi" "github.com/go-faster/oteldb/internal/otelstorage" @@ -273,8 +274,12 @@ func (h *LokiAPI) Series(ctx context.Context, params lokiapi.SeriesParams) (*lok // // Used for common default response. func (h *LokiAPI) NewError(_ context.Context, err error) *lokiapi.ErrorStatusCode { + code := http.StatusBadRequest + if _, ok := errors.Into[*logqlerrors.UnsupportedError](err); ok { + code = http.StatusNotImplemented + } return &lokiapi.ErrorStatusCode{ - StatusCode: http.StatusBadRequest, + StatusCode: code, Response: lokiapi.Error(err.Error()), } }