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).
This commit is contained in:
x-stp
2026-04-18 15:29:57 +02:00
parent 664f5b740f
commit c61d1e9be6
+1 -1
View File
@@ -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