From 8b6ba22b90cd7a37c3d249536d5fbb81af649c8b Mon Sep 17 00:00:00 2001 From: Sinspired <63581268+sinspired@users.noreply.github.com> Date: Wed, 26 Nov 2025 10:35:26 +0800 Subject: [PATCH] fix: replace wrong SetString() with SetBool() for uint weak-typed input (#2394) The uint branch in decodeBool() incorrectly used SetString(). Use SetBool(dataVal.Uint() != 0) to match expected behavior. --- common/structure/structure.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/structure/structure.go b/common/structure/structure.go index bf79f7dd..840e4f6c 100644 --- a/common/structure/structure.go +++ b/common/structure/structure.go @@ -289,7 +289,7 @@ func (d *Decoder) decodeBool(name string, data any, val reflect.Value) (err erro case isInt(kind) && d.option.WeaklyTypedInput: val.SetBool(dataVal.Int() != 0) case isUint(kind) && d.option.WeaklyTypedInput: - val.SetString(strconv.FormatUint(dataVal.Uint(), 10)) + val.SetBool(dataVal.Uint() != 0) default: err = fmt.Errorf( "'%s' expected type '%s', got unconvertible type '%s'",