From c61d1e9be64112ff83743c23d4341667213076d0 Mon Sep 17 00:00:00 2001 From: x-stp Date: Sat, 18 Apr 2026 15:29:57 +0200 Subject: [PATCH] fix(chinaz): accept empty arrays, check ValueType over truthiness Addresses CodeRabbit review: jsoniter's ToBool returns false for empty arrays as well as missing keys, so a valid response with ContributingSubdomainList: [] would incorrectly trip the shape-mismatch branch. Switch to ValueType() != ArrayValue; the iteration loop handles empty arrays naturally (0 results, no error emitted). --- pkg/subscraping/sources/chinaz/chinaz.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/subscraping/sources/chinaz/chinaz.go b/pkg/subscraping/sources/chinaz/chinaz.go index 22294d5b..5e545b40 100644 --- a/pkg/subscraping/sources/chinaz/chinaz.go +++ b/pkg/subscraping/sources/chinaz/chinaz.go @@ -58,7 +58,7 @@ func (s *Source) Run(ctx context.Context, domain string, session *subscraping.Se } SubdomainList := jsoniter.Get(body, "Result").Get("ContributingSubdomainList") - if !SubdomainList.ToBool() { + if SubdomainList.ValueType() != jsoniter.ArrayValue { results <- subscraping.Result{Source: s.Name(), Type: subscraping.Error, Error: fmt.Errorf("chinaz: unexpected response shape, missing Result.ContributingSubdomainList")} s.errors++ return