@@ -2,9 +2,10 @@ package authorization
22
33import (
44 "context"
5- "fmt"
65 "net/http"
76
7+ "github.com/go-kit/log"
8+ "github.com/go-kit/log/level"
89 "github.com/observatorium/api/authentication"
910 "github.com/observatorium/api/httperr"
1011 "github.com/observatorium/api/rbac"
@@ -61,7 +62,7 @@ func WithSelectorsInfo(ctx context.Context, info *SelectorsInfo) context.Context
6162
6263// WithLogsStreamSelectorsExtractor returns a middleware that, when enabled, tries to extract
6364// stream selectors from queries, so that they can be used in authorizing the request.
64- func WithLogsStreamSelectorsExtractor (selectorNames []string ) func (http.Handler ) http.Handler {
65+ func WithLogsStreamSelectorsExtractor (logger log. Logger , selectorNames []string ) func (http.Handler ) http.Handler {
6566 enabled := len (selectorNames ) > 0
6667
6768 selectorNameMap := make (map [string ]bool , len (selectorNames ))
@@ -79,9 +80,9 @@ func WithLogsStreamSelectorsExtractor(selectorNames []string) func(http.Handler)
7980
8081 selectorsInfo , err := extractLogStreamSelectors (selectorNameMap , r .URL .Query ())
8182 if err != nil {
82- httperr . PrometheusAPIError ( w , fmt . Sprintf ( " error extracting selectors from query: %s" , err ), http . StatusInternalServerError )
83-
84- return
83+ // Don't error out, just warn about error and continue with empty selectorsInfo
84+ level . Warn ( logger ). Log ( "msg" , err )
85+ selectorsInfo = emptySelectorsInfo
8586 }
8687
8788 next .ServeHTTP (w , r .WithContext (WithSelectorsInfo (r .Context (), selectorsInfo )))
0 commit comments