{"record":{"id":"753633933530738f","repo":"fish2018/pansou","slug":"s-753633","errorCode":null,"errorMessage":"[%s] 关键词不能为空","messagePattern":"\\[(.+?)\\] 关键词不能为空","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"plugin/mizixing/mizixing.go","lineNumber":103,"sourceCode":"\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn result.Results, nil\n}\n\n// SearchWithResult entrypoint\nfunc (p *MizixingPlugin) SearchWithResult(keyword string, ext map[string]interface{}) (model.PluginSearchResult, error) {\n\treturn p.AsyncSearchWithResult(keyword, p.searchImpl, p.MainCacheKey, ext)\n}\n\nfunc (p *MizixingPlugin) searchImpl(client *http.Client, keyword string, ext map[string]interface{}) ([]model.SearchResult, error) {\n\tif p.client != nil {\n\t\tclient = p.client\n\t}\n\n\tsearchKeyword := strings.TrimSpace(keyword)\n\tif searchKeyword == \"\" {\n\t\treturn nil, fmt.Errorf(\"[%s] 关键词不能为空\", p.Name())\n\t}\n\n\titems, err := p.fetchSearchResults(client, searchKeyword)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(items) == 0 {\n\t\treturn nil, fmt.Errorf(\"[%s] 未找到相关资源\", p.Name())\n\t}\n\n\tvar (\n\t\twg      sync.WaitGroup\n\t\tsem     = make(chan struct{}, detailWorkers)\n\t\tresultM sync.Mutex\n\t\tresults []model.SearchResult\n\t)\n\n\tfor _, item := range items {","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/mizixing/mizixing.go#L85-L121","documentation":"The mizixing search plugin validates its input: after trimming whitespace, the keyword must be non-empty. It returns this error naming the plugin rather than issuing a pointless network request. Purely an input-validation error.","triggerScenarios":"Calling the plugin's search with \"\" or a whitespace-only keyword string.","commonSituations":"UI/form code forwarding an empty search box value; upstream pipeline stripping a query to whitespace; programmatic callers passing uninitialized strings.","solutions":["Trim and check the keyword before calling search; skip the call if empty.","Return an empty result set to the user for empty queries instead of invoking the plugin.","Validate search input at the API/UI boundary."],"exampleFix":"// before\nresults, err := p.searchImpl(ctx, keyword)\n// after\nkeyword = strings.TrimSpace(keyword)\nif keyword == \"\" {\n    return nil, nil\n}\nresults, err := p.searchImpl(ctx, keyword)","handlingStrategy":"validation","validationCode":"kw := strings.TrimSpace(userQuery)\nif kw == \"\" {\n    return nil, nil // or a client-side \"enter a keyword\" response\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always trim and non-empty-check user input before search.","Validate search parameters at the API boundary.","Return empty results instead of invoking plugins for blank queries."],"tags":["input-validation","search","empty-input"],"backgroundTag":"empty-required-field","analyzedSha":"beaa56133755a548ebc51b090b3816e2ae044aa6","analyzedAt":"2026-09-07T00:31:18.025Z","contentChangedAt":"2026-09-07T00:31:18.025Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}