Tencent/WeKnora · error

invalid Zhipu content size: %s

Error message

invalid Zhipu content size: %s

What it means

Returned by ValidateZhipuParameters when the content size option derived from ExtraConfig is not one of Zhipu's accepted values. It bounds how much page content Zhipu returns per result; an unrecognized value fails provider configuration.

Source

Thrown at internal/infrastructure/web_search/zhipu.go:80

		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
}

// Name returns the provider name.
func (p *ZhipuProvider) Name() string {

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Set content_size in ExtraConfig to a supported Zhipu value
  2. Remove the key to use the default content size

Example fix

// before
cfg := map[string]string{"content_size": "huge"}
// after
cfg := map[string]string{"content_size": "high"} // must be a validZhipuContentSizes member
Defensive patterns

Strategy: validation

Validate before calling

func validateContentSize(cfg map[string]string) error {
    s := cfg["content_size"]
    if s == "" { return nil } // default applies
    for _, v := range validZhipuContentSizes { if s == v { return nil } }
    return fmt.Errorf("unsupported content_size %q", s)
}

Try / catch

provider, err := NewZhipuProvider(params)
if err != nil {
    if strings.Contains(err.Error(), "invalid Zhipu content size") {
        return fmt.Errorf("check ExtraConfig[content_size]; allowed values are in validZhipuContentSizes: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: Calling NewZhipuProvider / ValidateZhipuParameters with ExtraConfig["content_size"] set to a value not in the allowed set (e.g. "huge" instead of the supported small/medium/large-style values).

Common situations: Typos, using values from other providers' config formats, guessing allowed values without checking validZhipuContentSizes, or config generated from outdated documentation.

Related errors


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/a7cf0d62030c4178. Report an issue: GitHub.