Tencent/WeKnora · error
invalid Metaso search scope: %s
Error message
invalid Metaso search scope: %s
What it means
Returned by ValidateMetasoParameters when the configured Metaso search scope (derived from ExtraConfig["scope"]) is not one of the entries in validMetasoScopes. Metaso only accepts a fixed set of scopes (e.g. webpage/document/image etc.), and an unknown value would cause API-side rejections, so the provider validates it up front. The invalid value is included in the message.
Source
Thrown at internal/infrastructure/web_search/metaso.go:60
return nil, err
}
client, err := NewSearchHTTPClient(defaultMetasoTimeout, params.ProxyURL)
if err != nil {
return nil, err
}
return &MetasoProvider{
client: client, baseURL: defaultMetasoSearchURL,
apiKey: strings.TrimSpace(params.APIKey), scope: metasoScope(params.ExtraConfig),
}, nil
}
func ValidateMetasoParameters(params types.WebSearchProviderParameters) error {
if strings.TrimSpace(params.APIKey) == "" {
return fmt.Errorf("API key is required for Metaso provider")
}
scope := metasoScope(params.ExtraConfig)
if _, ok := validMetasoScopes[scope]; !ok {
return fmt.Errorf("invalid Metaso search scope: %s", scope)
}
return nil
}
func metasoScope(extraConfig map[string]string) string {
if scope := strings.TrimSpace(extraConfig["scope"]); scope != "" {
return scope
}
return defaultMetasoScope
}
func (p *MetasoProvider) Name() string { return "metaso" }
func (p *MetasoProvider) Search(ctx context.Context, query string, maxResults int, includeDate bool) ([]*types.WebSearchResult, error) {
query = strings.TrimSpace(query)
if query == "" {
return nil, fmt.Errorf("query is empty")
}View on GitHub (pinned to 988cbb0330)
Solutions
- Check the error message for the offending scope value and compare against the provider's validMetasoScopes list (see metaso.go).
- Set ExtraConfig["scope"] to one of the documented valid values (or omit it entirely to use the default).
- Fix casing/typos — scopes are matched exactly, not case-insensitively.
- Add a whitelist check in your own config loading to reject bad scopes before constructing the provider.
Example fix
// before
cfg := types.WebSearchProviderParameters{APIKey: key, ExtraConfig: map[string]string{"scope": "web"}}
// after: use a documented valid scope
cfg := types.WebSearchProviderParameters{APIKey: key, ExtraConfig: map[string]string{"scope": "webpage"}} Defensive patterns
Strategy: validation
Validate before calling
var validMetasoScopes = map[string]bool{"webpage": true, "document": true, "image": true}
scope := strings.TrimSpace(cfg.ExtraConfig["scope"])
if scope != "" && !validMetasoScopes[scope] {
return fmt.Errorf("invalid Metaso scope %q; valid: webpage, document, image", scope)
} Try / catch
if err := ValidateMetasoParameters(params); err != nil {
if strings.Contains(err.Error(), "invalid Metaso search scope") {
return nil, fmt.Errorf("check your scope setting: %w", err)
}
return err
} Prevention
- Expose scopes as a fixed enum in your own config layer, not free-form strings.
- Copy scope names from the provider's documentation/validMetasoScopes, not from other providers.
- Add a unit test asserting every scope your app configures passes ValidateMetasoParameters.
- Prefer omitting ExtraConfig["scope"] to use the default when unsure.
When it happens
Trigger: NewMetasoProvider -> ValidateMetasoParameters where metasoScope(params.ExtraConfig) returns a value not in validMetasoScopes — e.g. ExtraConfig{scope: "web"} when the provider expects "webpage", a typo, or wrong casing.
Common situations: Copy-pasted scope name from another provider's config; typo like "webpages" vs "webpage"; user-facing setting passing free-form text into scope; empty-but-set value that skips the default and is not whitelisted.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- API key is required for Ollama provider
- API key is required for Metaso provider
- sandbox: config is missing required fields
- S3 access key and secret key must be provided together
- ErrNamedSandboxBackendUnsupported
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/07cb698fa511b465.
Report an issue: GitHub.