Skip to content

Commit

Permalink
Merge branch 'main' into list-pagination
Browse files Browse the repository at this point in the history
* main:
  mod tidy
  Update changelog for release
  Fix parse error for bool/number to not return 500 (#1047)
  Bump codecov/codecov-action from 3.1.0 to 3.1.1 (#1043)
  • Loading branch information
markphelps committed Sep 30, 2022
2 parents 134fa2f + 5518bc5 commit 1d01cb3
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
run: go test -race -covermode=atomic -coverprofile=coverage.txt -count=1 ./...

- name: Upload Coverage
uses: codecov/codecov-action@v3.1.0
uses: codecov/codecov-action@v3.1.1

database:
name: Database Test
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
This format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [v1.12.1](https://github.com/markphelps/flipt/releases/tag/v1.12.1) - 2022-09-30

### Fixed

- Issue where parsing value with incorrect type would return 500 from the evaluation API [#1047](https://github.com/flipt-io/flipt/pull/1047)

### Changed

- Dependency updates
- Use testcontainers for MySQL/Postgres tests to run locally [#1045](https://github.com/flipt-io/flipt/pull/1045)

## [v1.12.0](https://github.com/markphelps/flipt/releases/tag/v1.12.0) - 2022-09-22

### Added
Expand Down
8 changes: 4 additions & 4 deletions server/evaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package server
import (
"context"
"errors"
"fmt"
"hash/crc32"
"sort"
"strconv"
Expand Down Expand Up @@ -294,12 +293,13 @@ func matchesNumber(c storage.EvaluationConstraint, v string) (bool, error) {

n, err := strconv.ParseFloat(v, 64)
if err != nil {
return false, fmt.Errorf("parsing number from %q", v)
return false, errs.ErrInvalidf("parsing number from %q", v)
}

// TODO: we should consider parsing this at creation time since it doesn't change and it doesnt make sense to allow invalid constraint values
value, err := strconv.ParseFloat(c.Value, 64)
if err != nil {
return false, fmt.Errorf("parsing number from %q", c.Value)
return false, errs.ErrInvalidf("parsing number from %q", c.Value)
}

switch c.Operator {
Expand Down Expand Up @@ -335,7 +335,7 @@ func matchesBool(c storage.EvaluationConstraint, v string) (bool, error) {

value, err := strconv.ParseBool(v)
if err != nil {
return false, fmt.Errorf("parsing boolean from %q", v)
return false, errs.ErrInvalidf("parsing boolean from %q", v)
}

switch c.Operator {
Expand Down
12 changes: 8 additions & 4 deletions server/evaluator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
"go.flipt.io/flipt/errors"
errs "go.flipt.io/flipt/errors"
flipt "go.flipt.io/flipt/rpc/flipt"
"go.flipt.io/flipt/storage"
"go.uber.org/zap/zaptest"
Expand Down Expand Up @@ -83,7 +83,7 @@ func TestBatchEvaluate_FlagNotFoundExcluded(t *testing.T) {
}
store.On("GetFlag", mock.Anything, "foo").Return(enabledFlag, nil)
store.On("GetFlag", mock.Anything, "bar").Return(disabled, nil)
store.On("GetFlag", mock.Anything, "NotFoundFlag").Return(&flipt.Flag{}, errors.ErrNotFoundf("flag %q", "NotFoundFlag"))
store.On("GetFlag", mock.Anything, "NotFoundFlag").Return(&flipt.Flag{}, errs.ErrNotFoundf("flag %q", "NotFoundFlag"))

store.On("GetEvaluationRules", mock.Anything, "foo").Return([]*storage.EvaluationRule{}, nil)

Expand Down Expand Up @@ -131,7 +131,7 @@ func TestBatchEvaluate_FlagNotFound(t *testing.T) {
}
store.On("GetFlag", mock.Anything, "foo").Return(enabledFlag, nil)
store.On("GetFlag", mock.Anything, "bar").Return(disabled, nil)
store.On("GetFlag", mock.Anything, "NotFoundFlag").Return(&flipt.Flag{}, errors.ErrNotFoundf("flag %q", "NotFoundFlag"))
store.On("GetFlag", mock.Anything, "NotFoundFlag").Return(&flipt.Flag{}, errs.ErrNotFoundf("flag %q", "NotFoundFlag"))

store.On("GetEvaluationRules", mock.Anything, "foo").Return([]*storage.EvaluationRule{}, nil)

Expand Down Expand Up @@ -171,7 +171,7 @@ func TestEvaluate_FlagNotFound(t *testing.T) {
}
)

store.On("GetFlag", mock.Anything, "foo").Return(&flipt.Flag{}, errors.ErrNotFoundf("flag %q", "foo"))
store.On("GetFlag", mock.Anything, "foo").Return(&flipt.Flag{}, errs.ErrNotFoundf("flag %q", "foo"))

resp, err := s.Evaluate(context.TODO(), &flipt.EvaluationRequest{
EntityId: "1",
Expand Down Expand Up @@ -1952,6 +1952,8 @@ func Test_matchesNumber(t *testing.T) {

if wantErr {
require.Error(t, err)
var ierr errs.ErrInvalid
require.ErrorAs(t, err, &ierr)
return
}

Expand Down Expand Up @@ -2074,6 +2076,8 @@ func Test_matchesBool(t *testing.T) {

if wantErr {
require.Error(t, err)
var ierr errs.ErrInvalid
require.ErrorAs(t, err, &ierr)
return
}

Expand Down
3 changes: 2 additions & 1 deletion storage/sql/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,13 @@ func TestParse(t *testing.T) {
driver = tt.driver
url = tt.dsn
wantErr = tt.wantErr
opts = tt.options
)

t.Run(tt.name, func(t *testing.T) {
d, u, err := parse(config.Config{
Database: cfg,
}, tt.options)
}, opts)

if wantErr {
require.Error(t, err)
Expand Down
10 changes: 9 additions & 1 deletion ui/src/components/Flags/DebugConsole.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,15 @@ export default {
this.response = response.data;
})
.catch((error) => {
this.response = { error: error.response.data.error };
if (error.response) {
this.response = {
error: error.response.data.message,
};
} else {
this.response = {
error: error.message,
};
}
});
},
},
Expand Down

0 comments on commit 1d01cb3

Please sign in to comment.