fish2018/pansou · warning

[ ] 关键词不能为空

Error message

[%s] 关键词不能为空

What it means

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.

Solutions

  1. Trim and check the keyword before calling search; skip the call if empty.
  2. Return an empty result set to the user for empty queries instead of invoking the plugin.
  3. Validate search input at the API/UI boundary.

Example fix

// before
results, err := p.searchImpl(ctx, keyword)
// after
keyword = strings.TrimSpace(keyword)
if keyword == "" {
    return nil, nil
}
results, err := p.searchImpl(ctx, keyword)
Defensive patterns

Strategy: validation

Validate before calling

kw := strings.TrimSpace(userQuery)
if kw == "" {
    return nil, nil // or a client-side "enter a keyword" response
}

Prevention

When it happens

Trigger: Calling the plugin's search with "" or a whitespace-only keyword string.

Common situations: UI/form code forwarding an empty search box value; upstream pipeline stripping a query to whitespace; programmatic callers passing uninitialized strings.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of fish2018/pansou@beaa561337 (2026-09-07). Data as JSON: /api/errors/753633933530738f. Report an issue: GitHub.

Appendix: source

Thrown at plugin/mizixing/mizixing.go:103

	if err != nil {
		return nil, err
	}
	return result.Results, nil
}

// SearchWithResult entrypoint
func (p *MizixingPlugin) SearchWithResult(keyword string, ext map[string]interface{}) (model.PluginSearchResult, error) {
	return p.AsyncSearchWithResult(keyword, p.searchImpl, p.MainCacheKey, ext)
}

func (p *MizixingPlugin) searchImpl(client *http.Client, keyword string, ext map[string]interface{}) ([]model.SearchResult, error) {
	if p.client != nil {
		client = p.client
	}

	searchKeyword := strings.TrimSpace(keyword)
	if searchKeyword == "" {
		return nil, fmt.Errorf("[%s] 关键词不能为空", p.Name())
	}

	items, err := p.fetchSearchResults(client, searchKeyword)
	if err != nil {
		return nil, err
	}
	if len(items) == 0 {
		return nil, fmt.Errorf("[%s] 未找到相关资源", p.Name())
	}

	var (
		wg      sync.WaitGroup
		sem     = make(chan struct{}, detailWorkers)
		resultM sync.Mutex
		results []model.SearchResult
	)

	for _, item := range items {

View on GitHub (pinned to beaa561337)