Tencent/WeKnora · error
invalid Zhipu search engine: %s
Error message
invalid Zhipu search engine: %s
What it means
Returned by ValidateZhipuParameters when the search engine derived from ExtraConfig is not in validZhipuSearchEngines. Zhipu's Web Search API only accepts a fixed set of engine values, so an unknown entry makes the whole provider configuration invalid at creation time.
Source
Thrown at internal/infrastructure/web_search/zhipu.go:77
}
searchEngine, contentSize := zhipuOptions(params.ExtraConfig)
return &ZhipuProvider{
client: client,
baseURL: defaultZhipuSearchURL,
apiKey: strings.TrimSpace(params.APIKey),
searchEngine: searchEngine,
contentSize: contentSize,
}, nil
}
// ValidateZhipuParameters validates credentials and provider-specific options.
func ValidateZhipuParameters(params types.WebSearchProviderParameters) error {
if strings.TrimSpace(params.APIKey) == "" {
return fmt.Errorf("API key is required for Zhipu provider")
}
searchEngine, contentSize := zhipuOptions(params.ExtraConfig)
if _, ok := validZhipuSearchEngines[searchEngine]; !ok {
return fmt.Errorf("invalid Zhipu search engine: %s", searchEngine)
}
if _, ok := validZhipuContentSizes[contentSize]; !ok {
return fmt.Errorf("invalid Zhipu content size: %s", contentSize)
}
return nil
}
func zhipuOptions(extraConfig map[string]string) (searchEngine, contentSize string) {
searchEngine = defaultZhipuSearchEngine
contentSize = defaultZhipuContentSize
if value := strings.TrimSpace(extraConfig["search_engine"]); value != "" {
searchEngine = value
}
if value := strings.TrimSpace(extraConfig["content_size"]); value != "" {
contentSize = value
}
return searchEngine, contentSize
}View on GitHub (pinned to 988cbb0330)
Solutions
- Set search_engine in ExtraConfig to one of the supported Zhipu engines
- Remove the search_engine key to fall back to the default engine
Example fix
// before
cfg := map[string]string{"search_engine": "google"}
// after
cfg := map[string]string{"search_engine": "search_std_v2"} // must be a validZhipuSearchEngines member Defensive patterns
Strategy: validation
Validate before calling
func validateSearchEngine(cfg map[string]string) error {
e := cfg["search_engine"]
if e == "" { return nil } // default applies
for _, v := range validZhipuSearchEngines { if e == v { return nil } }
return fmt.Errorf("unsupported search_engine %q", e)
} Try / catch
provider, err := NewZhipuProvider(params)
if err != nil {
if strings.Contains(err.Error(), "invalid Zhipu search engine") {
return fmt.Errorf("check ExtraConfig[search_engine]; allowed values are in validZhipuSearchEngines: %w", err)
}
return err
} Prevention
- Keep a whitelist constant of allowed engine names in your app config
- Omit the option to use the provider default
- Copy option names from the library source, not memory
- Add a config schema validation step at startup
When it happens
Trigger: Calling NewZhipuProvider / ValidateZhipuParameters with ExtraConfig["search_engine"] set to a value not in the allowed set (e.g. "google", a typo like "search_std_v2" vs the supported keys).
Common situations: Copy-pasting engine names from other providers' configs, typos or wrong casing, using an engine name from an outdated Zhipu API version, or misreading documentation.
Related errors
- invalid Zhipu content size: %s
- API key is required for Zhipu provider
- query is empty
- invalid sandbox type
- timeout cannot be negative
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/e228f62d2c8b9c1d.
Report an issue: GitHub.