Skip to content

Commit ecdbcf8

Browse files
rickbijkerkRick Bijkerk
andauthored
Fix max tokens config mapping and reject_on_failure property (#17)
the `max_tokens` config in the yaml was ignored due to incorrect mapping The same applied to '`reject_on_failure`' boolean for both `max_aliases` and `max_tokens` --------- Co-authored-by: Rick Bijkerk <[email protected]>
1 parent 54a7674 commit ecdbcf8

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

cmd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ func middleware(log *slog.Logger, cfg *config.Config, po *persisted_operations.P
182182
httpInstrumentation := HttpInstrumentation()
183183

184184
aliases.NewMaxAliasesRule(cfg.MaxAliases)
185-
tks := tokens.MaxTokens(cfg.Token)
185+
tks := tokens.MaxTokens(cfg.MaxTokens)
186186
vr := ValidationRules(schema, tks)
187187

188188
fn := func(next http.Handler) http.Handler {

cmd/main_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,8 @@ type Product {
425425
}
426426
`,
427427
cfgOverrides: func(cfg *config.Config) *config.Config {
428-
cfg.Token.Enabled = true
429-
cfg.Token.Max = 1
428+
cfg.MaxTokens.Enabled = true
429+
cfg.MaxTokens.Max = 1
430430
return cfg
431431
},
432432
mockResponse: map[string]interface{}{

internal/app/config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ type Config struct {
2727
//DebugHost string `conf:"default:0.0.0.0:4000"`
2828
}
2929
Schema schema.Config `yaml:"schema"`
30-
Token tokens.Config `yaml:"token"`
3130
Target proxy.Config `yaml:"target"`
3231
PersistedOperations persisted_operations.Config `yaml:"persisted_operations"`
3332
BlockFieldSuggestions block_field_suggestions.Config `yaml:"block_field_suggestions"`
33+
MaxTokens tokens.Config `yaml:"max_tokens"`
3434
MaxAliases aliases.Config `yaml:"max_aliases"`
3535
}
3636

internal/business/aliases/aliases.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ var resultCounter = prometheus.NewCounterVec(prometheus.CounterOpts{
1919
type Config struct {
2020
Enabled bool `conf:"default:true" yaml:"enabled"`
2121
Max int `conf:"default:15" yaml:"max"`
22-
RejectOnFailure bool `conf:"default:true" yaml:"reject-on-failure"`
22+
RejectOnFailure bool `conf:"default:true" yaml:"reject_on_failure"`
2323
}
2424

2525
func init() {

internal/business/tokens/tokens.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ var resultCounter = prometheus.NewCounterVec(prometheus.CounterOpts{
1919
type Config struct {
2020
Enabled bool `conf:"default:true" yaml:"enabled"`
2121
Max int `conf:"default:1000" yaml:"max"`
22-
RejectOnFailure bool `conf:"default:true" yaml:"reject-on-failure"`
22+
RejectOnFailure bool `conf:"default:true" yaml:"reject_on_failure"`
2323
}
2424

2525
type MaxTokensRule struct {

0 commit comments

Comments
 (0)