fix(observability-proxy): reject negative limits at startup

Zero is the documented way to disable a limit; a negative value
disabled it too, silently. Refuse it so a typo in the chart cannot turn
off a per-user or total cap unnoticed.

Assisted-by: LLM
Signed-off-by: ZverGuy <maximbel2003@gmail.com>
This commit is contained in:
ZverGuy committed 2026-11-09 15:48:57 +07:00
1 parent d1c49b38d4
commit 8eef2fa5d2
2 files changed
+8

No files matched your search

+3
View File
@@ -104,6 +104,9 @@ func parseFlags(args []string) (options, error) {
return o, errors.New("--logs-max-tail-resume must not be negative")
case o.requestTimeout < 0 || o.tailIdleTimeout < 0 || o.authCacheTTL < 0 || o.shutdownTimeout < 0:
return o, errors.New("timeouts and the auth cache TTL must not be negative")
case o.limiter.RatePerUser < 0 || o.limiter.RateBurst < 0 || o.limiter.MaxConcurrentPerUser < 0 ||
o.limiter.MaxTailsPerUser < 0 || o.limiter.MaxTails < 0:
return o, errors.New("limits must not be negative; 0 disables a limit")
}
return o, nil
}
+5
View File
@@ -56,6 +56,11 @@ func TestParseFlagsInvalid(t *testing.T) {
{"--request-timeout=-1s"},
{"--tail-idle-timeout=-1s"},
{"--auth-cache-ttl=-1s"},
{"--rate-limit-per-user=-1"},
{"--rate-limit-burst=-1"},
{"--max-concurrent-per-user=-1"},
{"--max-tails-per-user=-1"},
{"--max-tails=-1"},
{"--unknown"},
} {
if _, err := parseFlags(args); err == nil {