From a6deb6ab902bc45fe388fe9fc63b3ce4010a3383 Mon Sep 17 00:00:00 2001 From: Gani Georgiev Date: Wed, 15 Jul 2026 13:23:13 +0300 Subject: [PATCH] fixed arg validation --- tools/rest/excerpt_modifier.go | 2 +- tools/rest/excerpt_modifier_test.go | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/tools/rest/excerpt_modifier.go b/tools/rest/excerpt_modifier.go index 07da1a06..b1ba3ee1 100644 --- a/tools/rest/excerpt_modifier.go +++ b/tools/rest/excerpt_modifier.go @@ -47,7 +47,7 @@ func newExcerptModifier(args ...string) (*excerptModifier, error) { } max := cast.ToInt(args[0]) - if max == 0 { + if max <= 0 { return nil, errors.New("max argument must be > 0") } diff --git a/tools/rest/excerpt_modifier_test.go b/tools/rest/excerpt_modifier_test.go index 47a87a66..a8078f9a 100644 --- a/tools/rest/excerpt_modifier_test.go +++ b/tools/rest/excerpt_modifier_test.go @@ -28,6 +28,16 @@ func TestNewExcerptModifier(t *testing.T) { []string{"something"}, // should fallback to 0 which is not allowed true, }, + { + "negative numeric max argument", + []string{"-1"}, + true, + }, + { + "zero numeric max argument", + []string{"0"}, + true, + }, { "numeric max argument", []string{"12"},