From 3c880378c98a30c137cf430c5783d7a0fae2bcc0 Mon Sep 17 00:00:00 2001 From: Gani Georgiev Date: Wed, 15 Jul 2026 11:51:15 +0300 Subject: [PATCH] fixed arg validation --- tools/picker/excerpt_modifier.go | 2 +- tools/picker/excerpt_modifier_test.go | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/tools/picker/excerpt_modifier.go b/tools/picker/excerpt_modifier.go index a60c842f..182d2ac3 100644 --- a/tools/picker/excerpt_modifier.go +++ b/tools/picker/excerpt_modifier.go @@ -53,7 +53,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/picker/excerpt_modifier_test.go b/tools/picker/excerpt_modifier_test.go index 7e5fe70a..ed1a6c17 100644 --- a/tools/picker/excerpt_modifier_test.go +++ b/tools/picker/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 max argument", + []string{"-1"}, + true, + }, + { + "zero max argument", + []string{"0"}, + true, + }, { "numeric max argument", []string{"12"},