Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: bad dynamicconfig filter/string mapping #6151

Merged
merged 2 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions common/dynamicconfig/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,17 @@ func TestDynamicConfigFilterTypeIsParseable(t *testing.T) {
}
}

func TestDynamicConfigFilterStringsCorrectly(t *testing.T) {
for _, filterString := range filters {
// filter-string-parsing and the resulting filter's String() must match
parsed := ParseFilter(filterString)
assert.Equal(t, filterString, parsed.String(), "filters need to String() correctly as some impls rely on it")
}
// should not be possible normally, but improper casting could trigger it
badFilter := Filter(len(filters))
assert.Equal(t, UnknownFilter.String(), badFilter.String(), "filters with indexes outside the list of known strings should String() to the unknown filter type")
}

func BenchmarkLogValue(b *testing.B) {
keys := []Key{
HistorySizeLimitError,
Expand Down
6 changes: 3 additions & 3 deletions common/dynamicconfig/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ import (
type Filter int

func (f Filter) String() string {
if f <= UnknownFilter || f > WorkflowID {
return filters[UnknownFilter]
if f > UnknownFilter && int(f) < len(filters) {
return filters[f]
}
return filters[f]
return filters[UnknownFilter]
Comment on lines -34 to +37
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

previously missed both workflowType and ratelimitKey 😢

}

func ParseFilter(filterName string) Filter {
Expand Down
Loading