Skip to content

Commit

Permalink
fix: more expressive errors (influxdata#22448)
Browse files Browse the repository at this point in the history
* fix: more expressive errors

Closes influxdata#22446

* fix: server only logging for untyped errors

* chore: fix formatting
  • Loading branch information
lesam authored Sep 13, 2021
1 parent 3e275a1 commit 5015297
Show file tree
Hide file tree
Showing 399 changed files with 586 additions and 871 deletions.
3 changes: 1 addition & 2 deletions authorization/http_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import (
"context"
"errors"

"github.com/influxdata/influxdb/v2/kit/platform"

"github.com/influxdata/influxdb/v2"
"github.com/influxdata/influxdb/v2/kit/platform"
"github.com/influxdata/influxdb/v2/pkg/httpc"
)

Expand Down
5 changes: 2 additions & 3 deletions authorization/http_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ import (
"net/http"
"time"

"github.com/influxdata/influxdb/v2/kit/platform"
"github.com/influxdata/influxdb/v2/kit/platform/errors"

"github.com/go-chi/chi"
"github.com/go-chi/chi/middleware"
"github.com/influxdata/influxdb/v2"
icontext "github.com/influxdata/influxdb/v2/context"
"github.com/influxdata/influxdb/v2/kit/platform"
"github.com/influxdata/influxdb/v2/kit/platform/errors"
kithttp "github.com/influxdata/influxdb/v2/kit/transport/http"
"go.uber.org/zap"
)
Expand Down
7 changes: 3 additions & 4 deletions authorization/http_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,17 @@ import (
"sort"
"testing"

"github.com/influxdata/influxdb/v2/kit/platform"
"github.com/influxdata/influxdb/v2/kit/platform/errors"
"github.com/stretchr/testify/require"

"github.com/go-chi/chi"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/influxdata/httprouter"
"github.com/influxdata/influxdb/v2"
icontext "github.com/influxdata/influxdb/v2/context"
"github.com/influxdata/influxdb/v2/kit/platform"
"github.com/influxdata/influxdb/v2/kit/platform/errors"
"github.com/influxdata/influxdb/v2/mock"
itesting "github.com/influxdata/influxdb/v2/testing"
"github.com/stretchr/testify/require"
"go.uber.org/zap/zaptest"
)

Expand Down
5 changes: 2 additions & 3 deletions authorization/middleware_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import (
"context"
"fmt"

"github.com/influxdata/influxdb/v2/kit/platform"
"github.com/influxdata/influxdb/v2/kit/platform/errors"

"github.com/influxdata/influxdb/v2"
"github.com/influxdata/influxdb/v2/authorizer"
"github.com/influxdata/influxdb/v2/kit/platform"
"github.com/influxdata/influxdb/v2/kit/platform/errors"
)

type AuthedAuthorizationService struct {
Expand Down
4 changes: 2 additions & 2 deletions authorization/middleware_auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package authorization_test
import (
"bytes"
"context"
"github.com/influxdata/influxdb/v2/kit/platform"
"github.com/influxdata/influxdb/v2/kit/platform/errors"
"sort"
"testing"

Expand All @@ -13,6 +11,8 @@ import (
"github.com/influxdata/influxdb/v2/authorization"
influxdbcontext "github.com/influxdata/influxdb/v2/context"
"github.com/influxdata/influxdb/v2/inmem"
"github.com/influxdata/influxdb/v2/kit/platform"
"github.com/influxdata/influxdb/v2/kit/platform/errors"
"github.com/influxdata/influxdb/v2/kv/migration/all"
"github.com/influxdata/influxdb/v2/mock"
"github.com/influxdata/influxdb/v2/tenant"
Expand Down
3 changes: 1 addition & 2 deletions authorization/middleware_logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import (
"fmt"
"time"

"github.com/influxdata/influxdb/v2/kit/platform"

"github.com/influxdata/influxdb/v2"
"github.com/influxdata/influxdb/v2/kit/platform"
"go.uber.org/zap"
)

Expand Down
3 changes: 1 addition & 2 deletions authorization/middleware_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ package authorization
import (
"context"

"github.com/influxdata/influxdb/v2/kit/platform"

"github.com/influxdata/influxdb/v2"
"github.com/influxdata/influxdb/v2/kit/metric"
"github.com/influxdata/influxdb/v2/kit/platform"
"github.com/prometheus/client_golang/prometheus"
)

Expand Down
3 changes: 1 addition & 2 deletions authorization/mock_tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ package authorization
import (
"context"

"github.com/influxdata/influxdb/v2/kit/platform"

"github.com/influxdata/influxdb/v2"
"github.com/influxdata/influxdb/v2/kit/platform"
)

// tenantService is a mock implementation of an authorization.tenantService
Expand Down
3 changes: 1 addition & 2 deletions authorization/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import (
"context"
"time"

"github.com/influxdata/influxdb/v2"
"github.com/influxdata/influxdb/v2/kit/platform"
"github.com/influxdata/influxdb/v2/kit/platform/errors"

"github.com/influxdata/influxdb/v2"
"github.com/influxdata/influxdb/v2/kv"
"github.com/influxdata/influxdb/v2/rand"
)
Expand Down
1 change: 0 additions & 1 deletion authorization/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/influxdata/influxdb/v2/kit/platform"
"github.com/influxdata/influxdb/v2/kit/platform/errors"

"github.com/influxdata/influxdb/v2/kit/tracing"
"github.com/influxdata/influxdb/v2/kv"
"github.com/influxdata/influxdb/v2/snowflake"
Expand Down
5 changes: 2 additions & 3 deletions authorization/storage_authorization.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import (
"context"
"encoding/json"

"github.com/influxdata/influxdb/v2/kit/platform"
"github.com/influxdata/influxdb/v2/kit/platform/errors"

"github.com/buger/jsonparser"
"github.com/influxdata/influxdb/v2"
"github.com/influxdata/influxdb/v2/kit/platform"
"github.com/influxdata/influxdb/v2/kit/platform/errors"
"github.com/influxdata/influxdb/v2/kv"
jsonp "github.com/influxdata/influxdb/v2/pkg/jsonparser"
)
Expand Down
2 changes: 1 addition & 1 deletion authorization/storage_authorization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package authorization_test
import (
"context"
"fmt"
"github.com/influxdata/influxdb/v2/kit/platform"
"reflect"
"testing"

"github.com/influxdata/influxdb/v2"
"github.com/influxdata/influxdb/v2/authorization"
"github.com/influxdata/influxdb/v2/inmem"
"github.com/influxdata/influxdb/v2/kit/platform"
"github.com/influxdata/influxdb/v2/kv"
"github.com/influxdata/influxdb/v2/kv/migration/all"
"go.uber.org/zap/zaptest"
Expand Down
3 changes: 1 addition & 2 deletions authorizer/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ package authorizer
import (
"context"

"github.com/influxdata/influxdb/v2"
"github.com/influxdata/influxdb/v2/kit/platform"
"github.com/influxdata/influxdb/v2/kit/platform/errors"

"github.com/influxdata/influxdb/v2"
)

// AuthAgent provides a means to authenticate users with resource and their associate actions. It
Expand Down
2 changes: 1 addition & 1 deletion authorizer/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package authorizer_test

import (
"context"
"github.com/influxdata/influxdb/v2/kit/platform"
"testing"

"github.com/influxdata/influxdb/v2"
"github.com/influxdata/influxdb/v2/authorizer"
icontext "github.com/influxdata/influxdb/v2/context"
"github.com/influxdata/influxdb/v2/kit/platform"
"github.com/influxdata/influxdb/v2/mock"
influxdbtesting "github.com/influxdata/influxdb/v2/testing"
"github.com/stretchr/testify/require"
Expand Down
3 changes: 1 addition & 2 deletions authorizer/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import (
"context"
"fmt"

"github.com/influxdata/influxdb/v2"
"github.com/influxdata/influxdb/v2/kit/platform"
"github.com/influxdata/influxdb/v2/kit/platform/errors"

"github.com/influxdata/influxdb/v2"
)

var _ influxdb.AuthorizationService = (*AuthorizationService)(nil)
Expand Down
4 changes: 2 additions & 2 deletions authorizer/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package authorizer_test
import (
"bytes"
"context"
"github.com/influxdata/influxdb/v2/kit/platform"
"github.com/influxdata/influxdb/v2/kit/platform/errors"
"sort"
"testing"

"github.com/google/go-cmp/cmp"
"github.com/influxdata/influxdb/v2"
"github.com/influxdata/influxdb/v2/authorizer"
influxdbcontext "github.com/influxdata/influxdb/v2/context"
"github.com/influxdata/influxdb/v2/kit/platform"
"github.com/influxdata/influxdb/v2/kit/platform/errors"
"github.com/influxdata/influxdb/v2/mock"
influxdbtesting "github.com/influxdata/influxdb/v2/testing"
)
Expand Down
5 changes: 2 additions & 3 deletions authorizer/authorize.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import (
"context"
"fmt"

"github.com/influxdata/influxdb/v2/kit/platform"
"github.com/influxdata/influxdb/v2/kit/platform/errors"

"github.com/influxdata/influxdb/v2"
icontext "github.com/influxdata/influxdb/v2/context"
"github.com/influxdata/influxdb/v2/kit/platform"
"github.com/influxdata/influxdb/v2/kit/platform/errors"
)

func isAllowedAll(a influxdb.Authorizer, permissions []influxdb.Permission) error {
Expand Down
3 changes: 1 addition & 2 deletions authorizer/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ package authorizer
import (
"context"

"github.com/influxdata/influxdb/v2/kit/platform"

"github.com/influxdata/influxdb/v2"
"github.com/influxdata/influxdb/v2/kit/platform"
"github.com/influxdata/influxdb/v2/kit/tracing"
)

Expand Down
4 changes: 2 additions & 2 deletions authorizer/bucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package authorizer_test
import (
"bytes"
"context"
"github.com/influxdata/influxdb/v2/kit/platform"
"github.com/influxdata/influxdb/v2/kit/platform/errors"
"sort"
"testing"

"github.com/google/go-cmp/cmp"
"github.com/influxdata/influxdb/v2"
"github.com/influxdata/influxdb/v2/authorizer"
influxdbcontext "github.com/influxdata/influxdb/v2/context"
"github.com/influxdata/influxdb/v2/kit/platform"
"github.com/influxdata/influxdb/v2/kit/platform/errors"
"github.com/influxdata/influxdb/v2/mock"
influxdbtesting "github.com/influxdata/influxdb/v2/testing"
)
Expand Down
4 changes: 2 additions & 2 deletions authorizer/check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package authorizer_test
import (
"bytes"
"context"
"github.com/influxdata/influxdb/v2/kit/platform"
"github.com/influxdata/influxdb/v2/kit/platform/errors"
"sort"
"testing"

"github.com/google/go-cmp/cmp"
"github.com/influxdata/influxdb/v2"
"github.com/influxdata/influxdb/v2/authorizer"
influxdbcontext "github.com/influxdata/influxdb/v2/context"
"github.com/influxdata/influxdb/v2/kit/platform"
"github.com/influxdata/influxdb/v2/kit/platform/errors"
"github.com/influxdata/influxdb/v2/mock"
"github.com/influxdata/influxdb/v2/notification/check"
influxdbtesting "github.com/influxdata/influxdb/v2/testing"
Expand Down
3 changes: 1 addition & 2 deletions authorizer/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ package authorizer
import (
"context"

"github.com/influxdata/influxdb/v2/kit/platform"

"github.com/influxdata/influxdb/v2"
"github.com/influxdata/influxdb/v2/kit/platform"
)

var _ influxdb.DashboardService = (*DashboardService)(nil)
Expand Down
4 changes: 2 additions & 2 deletions authorizer/dashboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package authorizer_test
import (
"bytes"
"context"
"github.com/influxdata/influxdb/v2/kit/platform"
"github.com/influxdata/influxdb/v2/kit/platform/errors"
"sort"
"testing"

"github.com/google/go-cmp/cmp"
"github.com/influxdata/influxdb/v2"
"github.com/influxdata/influxdb/v2/authorizer"
influxdbcontext "github.com/influxdata/influxdb/v2/context"
"github.com/influxdata/influxdb/v2/kit/platform"
"github.com/influxdata/influxdb/v2/kit/platform/errors"
"github.com/influxdata/influxdb/v2/mock"
influxdbtesting "github.com/influxdata/influxdb/v2/testing"
)
Expand Down
3 changes: 1 addition & 2 deletions authorizer/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import (
"context"
"fmt"

"github.com/influxdata/influxdb/v2/kit/platform"

"github.com/influxdata/influxdb/v2"
"github.com/influxdata/influxdb/v2/kit/platform"
)

var _ influxdb.DocumentService = (*DocumentService)(nil)
Expand Down
3 changes: 1 addition & 2 deletions authorizer/label.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ package authorizer
import (
"context"

"github.com/influxdata/influxdb/v2/kit/platform"

"github.com/influxdata/influxdb/v2"
"github.com/influxdata/influxdb/v2/kit/platform"
)

var _ influxdb.LabelService = (*LabelService)(nil)
Expand Down
4 changes: 2 additions & 2 deletions authorizer/label_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package authorizer_test
import (
"bytes"
"context"
"github.com/influxdata/influxdb/v2/kit/platform"
"github.com/influxdata/influxdb/v2/kit/platform/errors"
"sort"
"testing"

"github.com/google/go-cmp/cmp"
"github.com/influxdata/influxdb/v2"
"github.com/influxdata/influxdb/v2/authorizer"
influxdbcontext "github.com/influxdata/influxdb/v2/context"
"github.com/influxdata/influxdb/v2/kit/platform"
"github.com/influxdata/influxdb/v2/kit/platform/errors"
"github.com/influxdata/influxdb/v2/mock"
influxdbtesting "github.com/influxdata/influxdb/v2/testing"
)
Expand Down
3 changes: 1 addition & 2 deletions authorizer/notification_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ package authorizer
import (
"context"

"github.com/influxdata/influxdb/v2"
"github.com/influxdata/influxdb/v2/kit/platform"
"github.com/influxdata/influxdb/v2/kit/platform/errors"

"github.com/influxdata/influxdb/v2"
)

var _ influxdb.NotificationEndpointService = (*NotificationEndpointService)(nil)
Expand Down
4 changes: 2 additions & 2 deletions authorizer/notification_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package authorizer_test
import (
"bytes"
"context"
"github.com/influxdata/influxdb/v2/kit/platform"
"github.com/influxdata/influxdb/v2/kit/platform/errors"
"sort"
"testing"

"github.com/google/go-cmp/cmp"
"github.com/influxdata/influxdb/v2"
"github.com/influxdata/influxdb/v2/authorizer"
influxdbcontext "github.com/influxdata/influxdb/v2/context"
"github.com/influxdata/influxdb/v2/kit/platform"
"github.com/influxdata/influxdb/v2/kit/platform/errors"
"github.com/influxdata/influxdb/v2/mock"
"github.com/influxdata/influxdb/v2/notification/endpoint"
influxdbtesting "github.com/influxdata/influxdb/v2/testing"
Expand Down
3 changes: 1 addition & 2 deletions authorizer/notification_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ package authorizer
import (
"context"

"github.com/influxdata/influxdb/v2/kit/platform"

"github.com/influxdata/influxdb/v2"
"github.com/influxdata/influxdb/v2/kit/platform"
)

var _ influxdb.NotificationRuleStore = (*NotificationRuleStore)(nil)
Expand Down
Loading

0 comments on commit 5015297

Please sign in to comment.